This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: cgi.fieldStorage doesn't grok standards env. variables
Type: enhancement Stage: test needed
Components: Library (Lib) Versions: Python 3.2
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: orsenthil Nosy List: BreamoreBoy, Evgen.Koval, asvetlov, nimbustier, orsenthil, thezulk
Priority: normal Keywords: easy, patch

Created on 2004-02-19 09:09 by nimbustier, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue900112.diff thezulk, 2013-02-23 15:32 review
issue900112-3.3.diff Evgen.Koval, 2013-04-07 11:37 Same patch for 3.3 review
Messages (8)
msg60464 - (view) Author: Dominique Hazaël-Massieux (nimbustier) Date: 2004-02-19 09:09
The cgi.FieldStorage object has a headers property,
defined as:

"headers         : header dictionary-like object; default:
    taken from environ as per CGI spec"

But the CGI Spec gives a list of well-known environment
variables, plus a generic method to read environment
variables (those starting with HTTP_), that are *not*
read and parsred in this dictionary.
http://hoohoo.ncsa.uiuc.edu/cgi/env.html

msg109855 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2010-07-10 11:41
Original link is duff try this.
http://cgi-spec.golux.com/draft-coar-cgi-v11-03.txt
msg182750 - (view) Author: Andreas Åkerlund (thezulk) * Date: 2013-02-23 15:32
Submited a patch against 2.7 that adds all environment variables starting with "HTTP_", strips of the prefix and converts it to lower case. Also added a small test case.
msg186195 - (view) Author: Evgen Koval (Evgen.Koval) * Date: 2013-04-07 11:37
Patch for 3.3 is uploaded.
msg186574 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2013-04-11 18:32
I've found the stable link to CGI 1.1 spec at http://tools.ietf.org/html/draft-robinson-www-interface-00
Links to spec from the issue looks like broken.

Please, can you describe why we need to convert, say, HTTP_USER_AGENT to user-agent?

I see in the spec:
      Environment variables with names beginning with "HTTP_" contain
      header data read from the client, if the protocol used was HTTP.
      The HTTP header name is converted to upper case, has all
      occurrences of "-" replaced with "_" and has "HTTP_" prepended to
      give the environment variable name.

Why we need the reverse varname translation?
msg186575 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2013-04-11 18:37
Incidentally I was looking at this bug in the morning and it looks like this one is on the edge. Looks like we may not need the functionality as provided by the patch.

The existing headers are set in "FieldStorage" for use within the FieldStorage class. We do not need to get the headers out from environ variable and set in the FieldStorage headers. That is because we can already send the headers if we want as headers and environ are set by the users when Initializing FieldStorage object. 
So, I am really not sure of the utility value of the patch and gravitating towards closing this as Invalid. I am extremely sorry that this bug has been open for such a long time. But it also shows that not many have felt the need for this.
msg186616 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2013-04-12 11:11
Agree with Sentil
msg186632 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2013-04-12 14:03
I am closing this as an Invalid issue. Please bring to discussion at python-dev if someone disagrees. Thank you!
History
Date User Action Args
2022-04-11 14:56:02adminsetgithub: 39949
2013-04-12 14:03:10orsenthilsetstatus: open -> closed
resolution: not a bug
messages: + msg186632
2013-04-12 11:11:01asvetlovsetmessages: + msg186616
2013-04-11 18:37:41orsenthilsetmessages: + msg186575
2013-04-11 18:32:42asvetlovsetmessages: + msg186574
2013-04-07 11:37:12Evgen.Kovalsetfiles: + issue900112-3.3.diff
nosy: + asvetlov, Evgen.Koval
messages: + msg186195

2013-02-23 15:32:12thezulksetfiles: + issue900112.diff

nosy: + thezulk
messages: + msg182750

keywords: + patch
2010-07-11 05:53:10orsenthilsetassignee: orsenthil

nosy: + orsenthil
2010-07-10 11:41:21BreamoreBoysetnosy: + BreamoreBoy

messages: + msg109855
versions: + Python 3.2, - Python 2.7
2009-04-22 17:17:51ajaksu2setkeywords: + easy
2009-02-14 11:34:34ajaksu2setstage: test needed
type: enhancement
versions: + Python 2.7, - Python 2.3
2004-02-19 09:09:24nimbustiercreate