CURL & web.py: transfer closed with outstanding read data remaining

Posted by Richard J on Stack Overflow See other posts from Stack Overflow or by Richard J
Published on 2011-01-06T16:50:20Z Indexed on 2011/01/06 16:53 UTC
Read the original article Hit count: 421

Filed under:
|
|
|

Hi Folks,

I have written a web.py POST handler, thus:

import web

urls = ('/my', 'Test')

class Test:
    def POST(self):
        return "Here is your content"

app = web.application(urls, globals())
if __name__ == "__main__":
    app.run()

When I interact with it using Curl from the command line I get different responses depending on whether I post it any data or not:

curl -i -X POST http://localhost:8080/my

HTTP/1.1 200 OK
Transfer-Encoding: chunked
Date: Thu, 06 Jan 2011 16:42:41 GMT
Server: CherryPy/3.1.2 WSGI Server

Here is your content

(Posting of no data to the server gives me back the "Here is your content" string)

curl -i -X POST --data-binary "@example.zip" http://localhost:8080/my

HTTP/1.1 100
Content-Length: 0
Content-Type: text/plain

HTTP/1.1 200 OK
Transfer-Encoding: chunked
Date: Thu, 06 Jan 2011 16:43:47 GMT
Server: CherryPy/3.1.2 WSGI Server

curl: (18) transfer closed with outstanding read data remaining

(Posting example.zip to the server results in this error)

I've scoured the web.py documentation (what there is of it), and can't find any hints as to what might be going on here. Possibly something to do with 100 continue? I tried writing a python client which might help clarify:

h1 = httplib.HTTPConnection('localhost:8080')
h1.request("POST", "http://localhost:8080/my", body, headers)
print h1.getresponse()

body = the contents of the example.zip, and headers = empty dictionary. This request eventually timed out without printing anything, which I think exonerates curl from being the issue, so I believe something is going on in web.py which isn't quite right (or at least not sufficiently clear)

Any web.py experts got some tips?

Cheers,

Richard

© Stack Overflow or respective owner

Related posts about python

Related posts about http