Changeset 51242

Show
Ignore:
Timestamp:
02/23/07 14:32:36 (3 years ago)
Author:
bdelbosc
Message:

use urlencoding by default instead of mimeencoding for post

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • funkload/trunk/CHANGES.txt

    r51240 r51242  
    4848~~~~~~~~~ 
    4949 
    50 * fix: report with percentiles are buggy sometime P10 value is greater than MED 
     50* fix: # 1279_: Browser form submit encoding, default encoding for post is 
     51  now application/x-www-form-urlencoded, multipart mime encoding is used 
     52  only when uploading files. 
     53 
     54* fix: report with percentiles are buggy sometime P10 value is greater 
     55  than MED. 
    5156 
    5257* Patching webunit mimeEncode method to send CRLF as describe in RFC 1945 
     
    434439.. _1201: http://svn.nuxeo.org/trac/pub/ticket/1201 
    435440.. _1278: http://svn.nuxeo.org/trac/pub/ticket/1278 
     441.. _1279: http://svn.nuxeo.org/trac/pub/ticket/1279 
    436442.. _1282: http://svn.nuxeo.org/trac/pub/ticket/1282 
    437443.. _1283: http://svn.nuxeo.org/trac/pub/ticket/1283 
  • funkload/trunk/funkload/PatchWebunit.py

    r51240 r51242  
    2626* patching webunit mimeEncode to be rfc 1945 3.6.2 compliant using CRLF 
    2727* patching to remove cookie with a 'deleted' value 
     28* patching to have application/x-www-form-urlencoded by default and only 
     29  multipart when a file is posted 
    2830 
    2931$Id: PatchWebunit.py 24649 2005-08-29 14:20:19Z bdelbosc $ 
     
    3335import time 
    3436import urlparse 
     37from urllib import urlencode 
    3538import httplib 
    3639import cStringIO 
     
    7073                ret.write('\r\n') 
    7174            ret.write(sep_boundary) 
    72  
    73             # if key starts with a '$' then the entry is a file upload 
    7475            if isinstance(value, Upload): 
    7576                ret.write('\r\nContent-Disposition: form-data; name="%s"'%key) 
     
    251252    params = None 
    252253    if postdata: 
     254        if webproxy: 
     255            h.putrequest('POST', "http://%s%s" % (host_header, url)) 
     256        else: 
     257            # Normal post 
     258            h.putrequest('POST', url) 
     259        is_multipart = False 
    253260        for field, value in postdata.items(): 
    254261            if type(value) == type({}): 
    255262                postdata[field] = [] 
    256263                for k, selected in value.items(): 
    257                     if selected: postdata[field].append(k) 
    258  
    259         # Do a post with the data file 
    260         params = mimeEncode(postdata) 
    261         if webproxy: 
    262             h.putrequest('POST', "http://%s%s" % (host_header, url)) 
    263         else: 
    264             # Normal post 
    265             h.putrequest('POST', url) 
    266         h.putheader('Content-type', 'multipart/form-data; boundary=%s'% 
    267             BOUNDARY) 
     264                    if selected: 
     265                        postdata[field].append(k) 
     266            if isinstance(value, Upload): 
     267                # Post with a data file requires multipart mimeencode 
     268                is_multipart = True 
     269        if is_multipart: 
     270            params = mimeEncode(postdata) 
     271            h.putheader('Content-type', 'multipart/form-data; boundary=%s'% 
     272                        BOUNDARY) 
     273        else: 
     274            params = urlencode(postdata) 
     275            h.putheader('Content-type', 'application/x-www-form-urlencoded') 
    268276        h.putheader('Content-length', str(len(params))) 
    269277    else: