[csw-devel] SF.net SVN: gar:[13070] csw/mgar/gar/v2/lib/python/csw_upload_pkg.py

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Sun Jan 23 12:45:08 CET 2011


Revision: 13070
          http://gar.svn.sourceforge.net/gar/?rev=13070&view=rev
Author:   wahwah
Date:     2011-01-23 11:45:08 +0000 (Sun, 23 Jan 2011)

Log Message:
-----------
csw_upload_pkg: Fix proxy-related issues

When doing a HTTP PUT, a Content-Length header is required, so we need to
emulate data sending.

Also, working around the HTTP 417 error by setting 'Expect:' header to
nothing.

Modified Paths:
--------------
    csw/mgar/gar/v2/lib/python/csw_upload_pkg.py

Modified: csw/mgar/gar/v2/lib/python/csw_upload_pkg.py
===================================================================
--- csw/mgar/gar/v2/lib/python/csw_upload_pkg.py	2011-01-23 11:44:39 UTC (rev 13069)
+++ csw/mgar/gar/v2/lib/python/csw_upload_pkg.py	2011-01-23 11:45:08 UTC (rev 13070)
@@ -88,10 +88,16 @@
     c = pycurl.Curl()
     d = StringIO()
     h = StringIO()
+    # Bogus data to upload
+    s = StringIO()
     c.setopt(pycurl.URL, str(url))
     c.setopt(pycurl.PUT, 1)
+    c.setopt(pycurl.UPLOAD, 1)
+    c.setopt(pycurl.INFILESIZE_LARGE, s.len)
+    c.setopt(pycurl.READFUNCTION, s.read)
     c.setopt(pycurl.WRITEFUNCTION, d.write)
     c.setopt(pycurl.HEADERFUNCTION, h.write)
+    c.setopt(pycurl.HTTPHEADER, ["Expect:"]) # Fixes the HTTP 417 error
     if self.debug:
       c.setopt(c.VERBOSE, 1)
     c.perform()
@@ -164,6 +170,7 @@
     c.setopt(pycurl.HTTPPOST, post_data)
     c.setopt(pycurl.WRITEFUNCTION, d.write)
     c.setopt(pycurl.HEADERFUNCTION, h.write)
+    c.setopt(pycurl.HTTPHEADER, ["Expect:"]) # Fixes the HTTP 417 error
     if self.debug:
       c.setopt(c.VERBOSE, 1)
     c.perform()


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.


More information about the devel mailing list