apache – cURL挂起:“没有块,没有关闭,没有大小.假设接近信号结束“

使用此命令将上载流传输到Apache /
PHP服务器时

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

该命令挂起如下:

* 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

<

现在,当没有大块,没有接近,没有大小.假设接近信号结束消息出现我在本地和服务器文件上做校验和以证明它们是相同的,它们是相同的.意味着文件成功上载,但由于某种原因,连接未关闭.

为什么这样,我该如何解决?我可以告诉cURL在整个文件上传后关闭连接吗?谢谢

最佳答案 您明确告诉curl忽略服务器设置的内容长度.因此,响应的结束将被假定为连接关闭.但是服务器没有关闭,因为它等待更多请求.

除此之外:我认为你不能只添加“Transfer-Encoding:chunked”作为自定义标题.仅告诉服务器内容将以块的形式发送是不够的,但curl实际上必须使用chunked编码,而这可能不是.

点赞