HTTP PUT uploads don't seem to work

jmrodrijmrodri Registered Users Posts: 19 Big grins
I'm trying to get HTTP PUT to work using python httplib. I made sure all of the headers were set and properly spelled (including case). I simply get a "Broken pipe" error message from the server.

Are there any examples of using httplib in python to upload via PUT? is HTTP PUT still a valid upload method?

<pre>
173 data = filename_get_data(filename)
174 size = len(data)
175 headers = {
176 "Content-Transfer-Encoding":'binary',
177 "Content-MD5":md5.new(data).hexdigest(),
178 "X-Smug-SessionID":sessionid,
179 "X-Smug-Version":'1.1.1',
180 "X-Smug-ResponseType": 'REST',
181 "X-Smug-AlbumID": albumid,
182 "X-Smug-FileName": filename
183 }
184
185 conn = httplib.HTTPConnection("upload.smugmug.com")
186 #conn = httplib.HTTPConnection("localhost")
187 conn.connect()
188 conn.set_debuglevel(5)
189 conn.request("PUT", filename, data, headers)
190 response = conn.getresponse()
191 print response.status, response.reason
192 print response.read()
193 conn.close()
</pre>

Comments

  • jmrodrijmrodri Registered Users Posts: 19 Big grins
    edited June 14, 2007
    What a difference a / makes
    The problem was on line 189, I forgot to put in the slash. The correct code should read:


    conn.request("PUT", '/' + filename, data, headers)Live and learn. Sorry to bother everyone.
Sign In or Register to comment.