@@ -257,6 +257,46 @@ def testPostRequestWithNonUtf8TextData(self):
257
257
self .assertEqual (fs .bytes_read , length )
258
258
self .assertEqual (fs .file .read (), content )
259
259
260
+ def testPostRequestWithTextDataAndQueryParams (self ):
261
+ text = 'The \u2603 by Raymond Briggs'
262
+ content = text .encode ('utf-8' )
263
+ length = len (content )
264
+ fs = FieldStorage (fp = BytesIO (content ), environ = {
265
+ 'CONTENT_LENGTH' : length , 'REQUEST_METHOD' : 'POST' ,
266
+ 'CONTENT_TYPE' : 'text/plain' ,
267
+ 'QUERY_STRING' : 'a=1&b=2&b=2' })
268
+ self .assertEqual (fs .headers , {
269
+ 'content-type' : 'text/plain' ,
270
+ 'content-length' : length })
271
+ self .assertEqual (fs .type , 'text/plain' )
272
+ self .assertEqual (fs .length , length )
273
+ self .assertEqual (fs .bytes_read , length )
274
+ self .assertEqual (fs .file .read (), text )
275
+ self .assertEqual (fs .getfirst ('a' ), '1' )
276
+ self .assertEqual (fs .getfirst ('b' ), '2' )
277
+ self .assertEqual (fs .getlist ('a' ), ['1' ])
278
+ self .assertEqual (fs .getlist ('b' ), ['2' , '2' ])
279
+
280
+ def testPostRequestWithBinaryDataAndQueryParams (self ):
281
+ content = b'\xfe \xff \xc0 '
282
+ length = len (content )
283
+ fs = FieldStorage (fp = BytesIO (content ), environ = {
284
+ 'REQUEST_METHOD' : 'POST' ,
285
+ 'CONTENT_LENGTH' : length ,
286
+ 'CONTENT_TYPE' : 'application/octet-stream' ,
287
+ 'QUERY_STRING' : 'a=1&b=2&b=2' })
288
+ self .assertEqual (fs .headers , {
289
+ 'content-type' : 'application/octet-stream' ,
290
+ 'content-length' : length })
291
+ self .assertEqual (fs .type , 'application/octet-stream' )
292
+ self .assertEqual (fs .length , length )
293
+ self .assertEqual (fs .bytes_read , length )
294
+ self .assertEqual (fs .file .read (), content )
295
+ self .assertEqual (fs .getfirst ('a' ), '1' )
296
+ self .assertEqual (fs .getfirst ('b' ), '2' )
297
+ self .assertEqual (fs .getlist ('a' ), ['1' ])
298
+ self .assertEqual (fs .getlist ('b' ), ['2' , '2' ])
299
+
260
300
def testPostRequestWithSmallPayloadWithContentLength (self ):
261
301
length = 1000 # much smaller than buffer size
262
302
payload = 'x' * length
0 commit comments