[Patches] [Patch #100837] urllib patch to simplify POST form query

noreply@sourceforge.net noreply@sourceforge.net
Wed, 23 Aug 2000 18:07:47 -0700


Patch #100837 has been updated. 

Project: 
Category: library
Status: Closed
Summary: urllib patch to simplify POST form query

Follow-Ups:

Date: 2000-Jul-10 08:49
By: VizNut

Comment:
(SourceForce tossed my comment for the original patch, so here it is.)


Current GET form query:

  filename, headers = urllib.urlretrieve( "%s?%s" %
                                          ( BASE_URL, urllib.urlencode( parms ) ),
                                          filename )

Desirable POST form query:

  filename, headers = urllib.urlretrieve( BASE_URL, filename,
                                          data=urllib.urlencode( parms ) )

Current POST form query:

  fp = urllib.urlopen( BASE_URL, urllib.urlencode( parms ) )
  
  tfp = open(filename, 'wb')
  bs = 1024*8
  block = fp.read(bs)
  while block:
      tfp.write(block)
      block = fp.read(bs)
  tfp.close()
  fp.close()

The latter is required because there is no way to feed the data parameters for the POST query to urlretrieve.  The chunked read is necessary because these forms sometimes generate datasets larger than virtual memory (as in this case).

-------------------------------------------------------

Date: 2000-Jul-12 10:04
By: moshez

Comment:
This looks cool! I'm +1 on this.
(I haven't tested this patch yet, so I'll need to. From a cursory glance at the implementation it looks quite straightforward)

-------------------------------------------------------

Date: 2000-Aug-15 13:33
By: tim_one

Comment:
Reassigned to Fred because Jeremy's gone.  Fred, know anything about this stuff?  Review or assign to someone else, please.
-------------------------------------------------------

Date: 2000-Aug-15 14:09
By: fdrake

Comment:
This patch requires documentation; please update to modify Doc/lib/liburllib.tex, or provide specific (unmarked) text in a comment.
-------------------------------------------------------

Date: 2000-Aug-22 03:32
By: moshez

Comment:
Documentation updates summary: add the following paragraph
(copied from urlopen's description) to urlretrieve's description:

If the \var{url} uses the \file{http:} scheme identifier, the optional
\var{data} argument may be given to specify a \code{POST} request
(normally the request type is \code{GET}).  The \var{data} argument
must in standard \file{application/x-www-form-urlencoded} format;
see the \function{urlencode()} function below.

And add the same paragraph to URLopener's retrieve method.

Additionally, of course, \optional{, data} should be added to the synopsis of these methods. 
 
-------------------------------------------------------

Date: 2000-Aug-23 21:07
By: fdrake

Comment:
Checked in both implementation and documentation portions; this is done.
-------------------------------------------------------

-------------------------------------------------------
For more info, visit:

http://sourceforge.net/patch/?func=detailpatch&patch_id=100837&group_id=5470