Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cURL hangs at: "no chunk, no close, no size. Assume close to signal end"

Tags:

curl

tcp

apache

When using this command to stream upload to a Apache/PHP server

curl -X POST \
-i --data-binary @customfile.app \
-H "Transfer-Encoding: chunked" \
-H "Content-Type: application/app" \
-H "X-CustomHeader1: customvalue1" \
-H "X-CustomHeader2: customvalue2" \
-H "X-CustomHeader3: customvalue3" \
-H "X-CustomHeader4: customvalue4" \
-H "X-CustomHeader5: customvalue5" \
-H "X-CustomHeader6: customvalue6" \
--ignore-content-length \
--progress-bar -vvv \
http://[DOMAIN]/upload.php

The command hangs as follows:

* Hostname was NOT found in DNS cache
*   Trying [IP_ADDRESS]...
* Connected to [DOMAIN] ([IP_ADDRESS]) port 80 (#0)
> POST /upload.php HTTP/1.1
> User-Agent: curl/7.37.1
> Host: [DOMAIN]
> Accept: */*
> Transfer-Encoding: chunked
> Content-Type: application/app
> X-CustomHeader1: customvalue1
> X-CustomHeader2: customvalue2
> X-CustomHeader3: customvalue3
> X-CustomHeader4: customvalue4
> X-CustomHeader5: customvalue5
> X-CustomHeader6: customvalue6
> Expect: 100-continue
>
< HTTP/1.1 100 Continue
HTTP/1.1 100 Continue

< HTTP/1.1 200 OK
HTTP/1.1 200 OK
< Content-Type: text/html; charset=UTF-8
Content-Type: text/html; charset=UTF-8
< Date: Thu, 12 Feb 2015 11:10:17 GMT
Date: Thu, 12 Feb 2015 11:10:17 GMT
* Server Apache is not blacklisted
< Server: Apache
Server: Apache
< Vary: Content-Type
Vary: Content-Type
< Content-Length: 0
Content-Length: 0
< Connection: keep-alive
Connection: keep-alive
* no chunk, no close, no size. Assume close to signal end

<

Now, when the no chunk, no close, no size. Assume close to signal end message appears I do a checksum on both the local and server file to prove they are both the same, which they are. Meaning that the file successfully uploads, but for some reason the connection is not closed.

Why is that and how do I resolve it? Can I tell cURL to close the connection when the whole file has been uploaded? Thanks

like image 970
Matt Votsikas Avatar asked Oct 19 '22 17:10

Matt Votsikas


1 Answers

You specifically tell curl to ignore the content-length set by the server. Because of this the end of the response will be assumed to be connection close. But the server does not close because it waits for more requests.

Apart from that: I don't think you can just add "Transfer-Encoding: chunked" as a custom header. It is not enough to tell the server that the content will be sent in chunks but curl actually has to use chunked encoding which it probably does not.

like image 170
Steffen Ullrich Avatar answered Oct 27 '22 08:10

Steffen Ullrich