Skip to content

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

MikkelHJuul
Copy link

@MikkelHJuul MikkelHJuul commented Nov 19, 2020

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

… the output of the SimpleHTTPRequestHandler looks, and which headers to send.
@the-knights-who-say-ni
Copy link

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 username

We couldn't find a bugs.python.org (b.p.o) account corresponding to the following GitHub usernames:

@MikkelHJuul

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!

@MikkelHJuul
Copy link
Author

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)

Mikkel Juul and others added 3 commits November 20, 2020 09:31
… 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
@MikkelHJuul
Copy link
Author

@the-knights-who-say-ni how can I reactivate you?

@MikkelHJuul
Copy link
Author

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

@MikkelHJuul
Copy link
Author

MikkelHJuul commented Nov 20, 2020

The CLA was signed as MJuul, for some reason, can I link the CLA in some way?
https://bugs.python.org/user?@template=clacheck&github_names=MJuul says {"MJuul":null}
while
https://bugs.python.org/user?@template=clacheck&github_names=MikkelHJuul says {"MikkelHJuul":false}
I dunno.. I signed it, but should I resign it as MikkelHJuul? (Copy paste error)

@tiran
Copy link
Member

tiran commented Nov 20, 2020

Your CLA hasn't been processed yet. It may take a couple of business days.

@MikkelHJuul
Copy link
Author

I implemented it as a proxy method as I described here, since it enables preserving the "old" html-method
a use case for this would be:

...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()

@MikkelHJuul
Copy link
Author

@tiran cla is still not signed? 2 week since?

Btw how long time does review take normally?

@github-actions
Copy link

github-actions bot commented Jan 4, 2021

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Jan 4, 2021
@MikkelHJuul
Copy link
Author

@ALL CLA error I have signed it something like three times!

@github-actions github-actions bot removed the stale Stale PR or inactive for long period of time. label Jan 5, 2021
@github-actions
Copy link

github-actions bot commented Feb 5, 2021

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Feb 5, 2021
@github-actions github-actions bot removed the stale Stale PR or inactive for long period of time. label Aug 1, 2022
@python-cla-bot
Copy link

The following commit authors need to sign the Contributor License Agreement:

CLA signed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants