Issue #951 resolved

Content-Length breaks curl on 100-Continue

Anonymous created an issue

Using Python 2.5.2, curl 7.19.5 and CherryPy 3.1.2. My code is the example taken from the top of wsgiserver.py.

Curl is exiting with 18, and the error you can see below. Some files given to curl with the --data option let curl exit with 0, while others cause curl to exit with a status of 18. If I tell curl to use http1.0 instead of 1.1, then curl exits successfully regardless of the file. The CherryPy wsgiserver appears to stop sending data after the "Server" header.

Preventing the simple_response function from sending the Content-Length header on 100-Continue seems to resolve this problem.

{{{

!python

def my_crazy_app(environ, start_response): status = '200 OK' response_headers = [('Content-type','text/plain')] start_response(status, response_headers) return ['Hello world!\n'] if name=='main': from cherrypy.wsgiserver import CherryPyWSGIServer server = CherryPyWSGIServer((host, port), my_crazy_app) server.start() }}}

{{{ 192% cat config/curl --header "User-Agent: POSC WITSML Client" --header "Connection: close"
--header "Pragma: no-cache"
--header "Cache-Control: no-cache"
--header "Content-Type: text/xml; charset='utf-8'"
--max-time 300 --max-redirs 5

192% curl --config config/curl --data @requests/GetFromStore_myWells.xml --trace-ascii test/GetFromStore_myWells.xml/trace.ascii.txt --header "Host: 192.168.11.28" --header "Port: 8080" --header "SoapAction: http://www.witsml.org/action/120/Store.WMLS_GetFromStore" --header "EndPointURL: /" http://192.168.11.28:8080/

== Info: About to connect() to 192.168.11.28 port 8080 (#0)

== Info: Trying 192.168.11.28... == Info: connected

== Info: Connected to 192.168.11.28 (192.168.11.28) port 8080 (#0)

=> Send header, 330 bytes (0x14a)

  0000: POST / HTTP/1.1

  0011: Accept: */*

  001e: User-Agent: POSC WITSML Client

  003e: Connection: close

  0051: Pragma: no-cache

  0063: Cache-Control: no-cache

  007c: Content-Type: text/xml; charset='utf-8'

  00a5: Host: 192.168.11.28

  00ba: Port: 8080

  00c6: SoapAction: http://www.witsml.org/action/120/Store.WMLS_GetFromS

  0106: tore

  010c: EndPointURL: /

  011c: Content-Length: 3036

  0132: Expect: 100-continue

  0148:

<= Recv header, 14 bytes (0xe)

  0000: HTTP/1.1 100

<= Recv header, 19 bytes (0x13)

  0000: Content-Length: 0

<= Recv header, 26 bytes (0x1a)

  0000: Content-Type: text/plain

<= Recv header, 17 bytes (0x11)

  0000: HTTP/1.1 200 OK

<= Recv header, 26 bytes (0x1a)

  0000: Content-type: text/plain

<= Recv header, 28 bytes (0x1c)

  0000: Transfer-Encoding: chunked

<= Recv header, 19 bytes (0x13)

  0000: Connection: close

<= Recv header, 37 bytes (0x25)

  0000: Date: Tue, 04 Aug 2009 22:04:09 GMT

<= Recv header, 36 bytes (0x24)

  0000: Server: CherryPy/3.1.2 WSGI Server

<= Recv header, 2 bytes (0x2)

  0000:

== Info: we are done reading and this is set to close, stop send

== Info: transfer closed with outstanding read data remaining

== Info: Closing connection #0

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

zsh: exit 18 curl --config config/curl --data @requests/GetFromStore_myWells.xml }}}

Reported by jasapp@gmail.com

Comments (4)

  1. Log in to comment