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.

Author Daniel Klein
Recipients Daniel Klein
Date 2018-06-27.16:06:08
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1530115568.42.0.56676864532.issue33982@psf.upfronthosting.co.za>
In-reply-to
Content
The documentation says "A form submitted via POST that also has a query string will contain both FieldStorage and MiniFieldStorage items." suggesting that I can have a query with bost a QUERY_STRING and POST parameters. The code backs this up most of the time...

In read_urlencoded() the initial query string is read from STDIN, and self.qs_on_post (i.e., env['QUERY_STRING']) is appended to that. This is what is called when the CONTENT_TYPE of the POST request is application/x-www-form-urlencoded. This leads to a FieldStorage object containing a list of MiniFieldStorage objects, like:

FieldStorage(None, None, [MiniFieldStorage('action', 'rate'), MiniFieldStorage('seq', '3'), MiniFieldStorage('version', '15')])


However, I am using a webhook interface from Google cloud, and it (legitimately!) does a POST with a CONTENT_TYPE of application/json.

When I call cgi.Fieldstorage(), the __init__ routine ultimately calls read_single().  This results in a FieldStorage object containing a single string as 

FieldStorage(None, None, '{"incident": {"incident_id": "0.ktptjso969s0","res...the rest of the JSON')

This results in a few problems.
1) The QUERY_STRING args are not parsed as promised
2) The FeildStorage object does not contain a list, and so will raise TypeError, "not indexable" if I try to use most of the other FieldStorage methods.
History
Date User Action Args
2018-06-27 16:06:08Daniel Kleinsetrecipients: + Daniel Klein
2018-06-27 16:06:08Daniel Kleinsetmessageid: <1530115568.42.0.56676864532.issue33982@psf.upfronthosting.co.za>
2018-06-27 16:06:08Daniel Kleinlinkissue33982 messages
2018-06-27 16:06:08Daniel Kleincreate