Allow custom headers in `http.server`
Hi CPython maintainers, I need to test my CORS setup and looking for a possibility to set a custom *Access-Control-Allow-Origin *header in http.server. As of now, there is no such feature. Are you interested in me writing a patch to contribute a feature of setting custom headers directly to `http.server`? Best, - Alex
Hello. This mailing list is to work on developing Python (adding new features to Python itself and fixing bugs); if you're having problems learning, understanding or using Python, please find another forum. Probably python-list/comp.lang.python mailing list/news group is the best place; there are Python developers who participate in it; you may get a faster, and probably more complete, answer there. See https://www.python.org/community/ for other lists/news groups/fora. Thank you for understanding. On Sat, Oct 26, 2019 at 03:29:03PM +0300, Alex Yursha <alexyursha@gmail.com> wrote:
Hi CPython maintainers,
I need to test my CORS setup and looking for a possibility to set a custom *Access-Control-Allow-Origin *header in http.server. As of now, there is no such feature. Are you interested in me writing a patch to contribute a feature of setting custom headers directly to `http.server`?
You can override method ``send_headers`` of the class ``HTTPRequestHandler`` and add your own headers. See an example at https://docs.aws.amazon.com/polly/latest/dg/example-Python-server-code.html
Best, - Alex
Oleg. -- Oleg Broytman https://phdru.name/ phd@phdru.name Programmers don't die, they just GOSUB without RETURN.
Is this not something you can do yourself by calling send_header() after calling send_response()? On Sat, Oct 26, 2019 at 7:33 AM Alex Yursha <alexyursha@gmail.com> wrote:
Hi CPython maintainers,
I need to test my CORS setup and looking for a possibility to set a custom *Access-Control-Allow-Origin *header in http.server. As of now, there is no such feature. Are you interested in me writing a patch to contribute a feature of setting custom headers directly to `http.server`?
Best, - Alex _______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-leave@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/TB3HCDXF... Code of Conduct: http://python.org/psf/codeofconduct/
-- --Guido van Rossum (python.org/~guido) *Pronouns: he/him **(why is my pronoun here?)* <http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/>
I thought about adding it as a command line option when invoked as `python3 -m http.server`. On Sat, Oct 26, 2019, 18:02 Guido van Rossum <guido@python.org> wrote:
Is this not something you can do yourself by calling send_header() after calling send_response()?
On Sat, Oct 26, 2019 at 7:33 AM Alex Yursha <alexyursha@gmail.com> wrote:
Hi CPython maintainers,
I need to test my CORS setup and looking for a possibility to set a custom *Access-Control-Allow-Origin *header in http.server. As of now, there is no such feature. Are you interested in me writing a patch to contribute a feature of setting custom headers directly to `http.server`?
Best, - Alex _______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-leave@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/TB3HCDXF... Code of Conduct: http://python.org/psf/codeofconduct/
-- --Guido van Rossum (python.org/~guido) *Pronouns: he/him **(why is my pronoun here?)* <http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/>
Probably python-list/comp.lang.python mailing list/news group is the best place
Since this involves a potential suggested change (adding a feature to assign custom headers to http.server), python-ideas or the "Ideas" section of https://discuss.python.org/ would also be appropriate. On Sat, Oct 26, 2019 at 11:05 AM Oleg Broytman <phd@phdru.name> wrote:
Hello.
This mailing list is to work on developing Python (adding new features to Python itself and fixing bugs); if you're having problems learning, understanding or using Python, please find another forum. Probably python-list/comp.lang.python mailing list/news group is the best place; there are Python developers who participate in it; you may get a faster, and probably more complete, answer there. See https://www.python.org/community/ for other lists/news groups/fora. Thank you for understanding.
On Sat, Oct 26, 2019 at 03:29:03PM +0300, Alex Yursha < alexyursha@gmail.com> wrote:
Hi CPython maintainers,
I need to test my CORS setup and looking for a possibility to set a custom *Access-Control-Allow-Origin *header in http.server. As of now, there is no such feature. Are you interested in me writing a patch to contribute a feature of setting custom headers directly to `http.server`?
You can override method ``send_headers`` of the class ``HTTPRequestHandler`` and add your own headers. See an example at
https://docs.aws.amazon.com/polly/latest/dg/example-Python-server-code.html
Best, - Alex
Oleg. -- Oleg Broytman https://phdru.name/ phd@phdru.name Programmers don't die, they just GOSUB without RETURN. _______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-leave@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/SSJL2BEQ... Code of Conduct: http://python.org/psf/codeofconduct/
participants (4)
-
Alex Yursha
-
Guido van Rossum
-
Kyle Stanley
-
Oleg Broytman