nickesk / pyactiveresource

Automatically exported from code.google.com/p/pyactiveresource
Other
0 stars 0 forks source link

Posts with no data have no Content-Length or Content-Type #6

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Many web servers puke when they get a HTTP POST or PUT with no
Content-Length and Content-Type. For example the Ruby on Rails Webrick
development server throws when they are missing.

In pyactiveresource, if you do a POST or PUT with no data the
Content-Length and Content-Type headers are missing.

Here is a svn patch to fix this. It just uses the default content type and
a length of zero, when there is no data.

Original issue reported on code.google.com by matthew....@gmail.com on 21 May 2009 at 11:25

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks, Matt. This looks good. I'll commit it on tues.

Original comment by mark.r.r...@gmail.com on 24 May 2009 at 1:03

GoogleCodeExporter commented 9 years ago
From my testing, it doesn't look like content-type is needed as long as
content-length is specified. Can you confirm this?

Original comment by mark.r.r...@gmail.com on 26 May 2009 at 7:45

GoogleCodeExporter commented 9 years ago

Original comment by mark.r.r...@gmail.com on 26 May 2009 at 8:23

GoogleCodeExporter commented 9 years ago
I just tested on webrick again. If there is a Content-Length, but no 
Content-Type the
server seems to try and guess the mime type. It guesses application/xml with xml
posts. But with other types like jpeg, it sometimes gets 
application/octet-stream or
image/jpeg. Other times it ignores the data completely.

Essentially, it may work fine with no Content-Type, because pyactiveresource 
just
uses XML. But once, or if it is updated to do other types of POST and PUT 
operations,
it should be included. 

For example, right now, if you want to upload a 10 MB file with POST, you need 
to
base64 it and put it inside xml. Ideally you would just attach the raw file to 
the
bottom of the http request and say the content type is image/jpeg.

So it is one of those grey areas. Where it does not matter now, but may later.

Original comment by matthew....@gmail.com on 26 May 2009 at 11:29