Re: [issue2551023] '-' in environment varibale

"John P. Rouillard" <[email protected]>
Newsgroups gmane.comp.bug-tracking.roundup.devel
Message-ID <[email protected]>
Hi Thomas:

In message <[email protected]>,
Thomas Arendsen Hein writes:
>* John P. Rouillard <[email protected]> [20190217 16:50]:
>> In message <[email protected]>,
>> =?utf-8?q?C=C3=A9dric_Krier?= writes:
>> >I use the wsgi_handler instead of roundup-server. And I can not get
>> >HTTP_X-REQUESTED-WITH set in environment because WSGI server convert all
>> >'-' into '_'.
>> 
>> What server are you using? That translation of '-' to _' is not
>> right/supported according to mod_wsgi or wsgi docs. It also seriously
>> breaks the compatibility with CGI.

Ok, I was talking nonsense.

>On the other hand I get variables like HTTP_USER_AGENT or
>HTTP_X_FORWARDED_FOR in a non-python CGI environment, too.

>I just checked 
>
>From https://www.ietf.org/rfc/rfc3875:
>(The Common Gateway Interface (CGI) Version 1.1)
>
>| 4.1.18.  Protocol-Specific Meta-Variables
>|
>|    Meta-variables with names beginning with "HTTP_" contain values read
>|    from the client request header fields, if the protocol used is HTTP.
>|    The HTTP header field name is converted to upper case, has all
>|    occurrences of "-" replaced with "_" and has "HTTP_" prepended to
>|    give the meta-variable name.
>

Ok, so I totally misremebered this.

>>Cedric said:
>> >I think roundup-server behavior should be normalized with other WSGI
>> >server and not use '-' in HTTP_*.
>> >I could not find in PEP3333 that '-' should be converted into '_' for
>> >HTTP_. There is only a reference to server-defined variables.
>> >
>> >https://www.python.org/dev/peps/pep-3333/#environ-variables
>> 

Apparently I implemented the wrong thing. I must have misconfigued my
test where I ran roundup as a pure cgi script. Worse, I relied on my
memory rather than looking up the cgi spec when I answered this
originally 8-(.

I agree 100% with Cedric's proposal to replace - with _ in roundup
server's mapping of HTTP headers into variables and changing the code
to match the _ form.

Thanks for the correction Thomas.

--
				-- rouilj
John Rouillard
===========================================================================
My employers don't acknowledge my existence much less my opinions.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.