Skip to content
This repository

Content-Length header is not set in response to a multipart POST request #64

Open
killing opened this Issue November 25, 2012 · 3 comments

2 participants

Jiaqiang Xu Mark Ellzey
Jiaqiang Xu

Recently I upgraded to libevhtp 1.1.17 from 0.4.10. In the server I wrote, I send back a redirect response to the browser after processing a multipart POST request. This works as expected for Chrome, but Firefox just waits indefinitely after sending the POST request. Before I upgraded libevhtp this works fine on both browsers.

Finally I found it's because the older version of evhtp will automatically add Content-Length=0 header to the response, while the new version won't. Firefox seems to expect this header.

I believe this is caused by a code change at evhtp.c:_evhtp_create_reply() function

if (htparser_get_multipart(request->conn->parser) == 1) {
    goto check_proto;
}

here the new code checks whether the request is multipart, while the old code checks whether the response is multipart.

Is this a bug?

Mark Ellzey
Owner

I will look into this, can you paste a query/response which triggers the bug?

Jiaqiang Xu

This is what I get from Chrome.

Request URL:http://gonggeng.org:8082/upload/c1073a3f?X-Progress-ID=30844c5b6ee8342446fc5bf0f4e835ae
Request Method:POST
Status Code:303 See Other
Request Headersview source
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Cache-Control:max-age=0
Connection:keep-alive
Content-Length:1526905
Content-Type:multipart/form-data; boundary=----WebKitFormBoundary4ob6p7w7s8D2Dh3z
Cookie:__utma=135118183.1275238224.1328753801.1334891967.1335624890.15; djdt=hide; django_language=zh-cn; csrftoken=a94964940837baaa16411701526ef58c
Host:gonggeng.org:8082
Origin:http://gonggeng.org
Referer:http://gonggeng.org/seahub/repo/f21b1c50-2803-459e-892a-c83c06adf0f3/
User-Agent:Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.2 (KHTML, like Gecko) Ubuntu/11.10 Chromium/15.0.874.106 Chrome/15.0.874.106 Safari/535.2
Query String Parametersview URL encoded
X-Progress-ID:30844c5b6ee8342446fc5bf0f4e835ae
Request Payload
------WebKitFormBoundary4ob6p7w7s8D2Dh3z
Content-Disposition: form-data; name="csrfmiddlewaretoken"

a94964940837baaa16411701526ef58c
------WebKitFormBoundary4ob6p7w7s8D2Dh3z
Content-Disposition: form-data; name="parent_dir"

/
------WebKitFormBoundary4ob6p7w7s8D2Dh3z
Content-Disposition: form-data; name="file"; filename="OReilly.Mastering.Regular.Expressions.3rd.Edition.Aug.2006.chm"
Content-Type: application/x-chm

------WebKitFormBoundary4ob6p7w7s8D2Dh3z--
Response Headersview source
Location:http://www.gonggeng.org/seahub/repo/f21b1c50-2803-459e-892a-c83c06adf0f3?p=%2F

Mark Ellzey
Owner

You are correct, and I'm an idiot. I will have the fix in the next rel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.