[Python-Dev] Re: Allow custom headers in `http.server`

2019-10-26 Thread Kyle Stanley
> 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  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 <
> alexyur...@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 Broytmanhttps://phdru.name/p...@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-le...@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/SSJL2BEQNII23ZGMLAXWYJYKTK35H6TO/
> Code of Conduct: http://python.org/psf/codeofconduct/
>
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@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/EUCMXIWKK4ICGAIOZ457LD7QUEDU7TTB/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: Allow custom headers in `http.server`

2019-10-26 Thread Alex Yursha
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  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  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-le...@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/TB3HCDXFED3G6VGSKSYLHYJICEDJ7FCA/
>> Code of Conduct: http://python.org/psf/codeofconduct/
>>
>
>
> --
> --Guido van Rossum (python.org/~guido)
> *Pronouns: he/him **(why is my pronoun here?)*
> 
>
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@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/SGUIPISTQXY526TIKWAKIKCQN3ECKTBP/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: Allow custom headers in `http.server`

2019-10-26 Thread Guido van Rossum
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  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-le...@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/TB3HCDXFED3G6VGSKSYLHYJICEDJ7FCA/
> Code of Conduct: http://python.org/psf/codeofconduct/
>


-- 
--Guido van Rossum (python.org/~guido)
*Pronouns: he/him **(why is my pronoun here?)*

___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@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/EBA6X3B2OP42O3AN5KV6ZCO7JV7UWXGE/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: Allow custom headers in `http.server`

2019-10-26 Thread Oleg Broytman
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  
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 Broytmanhttps://phdru.name/p...@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-le...@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/SSJL2BEQNII23ZGMLAXWYJYKTK35H6TO/
Code of Conduct: http://python.org/psf/codeofconduct/