-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
bpo-42063: Enable users of SimpleHTTPRequestHandler to more easily change behaviour #23414
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
… the output of the SimpleHTTPRequestHandler looks, and which headers to send.
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept this contribution by verifying everyone involved has signed the PSF contributor agreement (CLA). Recognized GitHub usernameWe couldn't find a bugs.python.org (b.p.o) account corresponding to the following GitHub usernames: This might be simply due to a missing "GitHub Name" entry in one's b.p.o account settings. This is necessary for legal reasons before we can look at this contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. You can check yourself to see if the CLA has been received. Thanks again for the contribution, we look forward to reviewing it! |
I will change to unencoded in stead, tomorrow. The regular user does not care about encoding the message (and it's tightly bound in the method anyway) |
… use that part to get a link for their implementation Removed encoding from the scope of the directory_body method Ran the IDEs auto indent/ auto format
@the-knights-who-say-ni how can I reactivate you? |
There may be some sense in adding a proxy method (in stead of going directly to the newly added directory_body-method), so that a user can override the proxy method in his/her class without removing the old implementation |
The CLA was signed as MJuul, for some reason, can I link the CLA in some way? |
Your CLA hasn't been processed yet. It may take a couple of business days. |
I implemented it as a proxy method as I described here, since it enables preserving the "old" html-method ...imports
def json_body(list_of_files, path, actual_path, enc):
return {"some": "json"}
def proxy_method(self, list_of_files, path, actual_path, enc):
if ('Content-type','application/json') in self.headers._headers:
return json_body(...)
else:
return self.directory_body_html(...)
Handler = SimpleHTTPRequestHandler
Handler.directory_body = proxy_method
TCPServer(("", 8000), Handler).serve_forever() |
@tiran cla is still not signed? 2 week since? Btw how long time does review take normally? |
This PR is stale because it has been open for 30 days with no activity. |
@ALL CLA error I have signed it something like three times! |
This PR is stale because it has been open for 30 days with no activity. |
The following commit authors need to sign the Contributor License Agreement: |
This pull request will enable implementing users to more simply override the rendering part of the SimpleHTTPRequestHandler.
It does not allow the user to add extra headers via configuration, but simply overriding the default behaviour is trivial.
For some examples, see the comments from the two added methods
https://bugs.python.org/issue42063