apache - cURL 卡在 : "no chunk, no close, no size. Assume close to signal end"

标签 apache curl tcp

当使用此命令将上传流式传输到 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

<

现在,没有 block ,没有关闭,没有大小。假设出现 close to signal end 消息,我对本地文件和服务器文件进行了校验和,以证明它们是相同的。表示文件上传成功,但由于某种原因连接没有关闭。

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

最佳答案

您专门告诉 curl 忽略服务器设置的内容长度。因此,响应的结束将被假定为连接关闭。但是服务器并没有关闭,因为它在等待更多的请求。

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

关于apache - cURL 卡在 : "no chunk, no close, no size. Assume close to signal end",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28476144/

相关文章:

ruby-on-rails - Pg 备份来自 Heroku 的 curl 最新转储

python - 如何保证数据完整发送? sendto(udp套接字)Python

php - 我怎样才能 curl 深度爬行?

c++ - 在 Linux 中获取 TCP/UDP 表

go - 有没有办法在不创建新的 goroutine 的情况下回调函数?

c# - 如何使用 mod_wsgi (django) 和 python 将文件从 C# 发送到 apache?

apache - SPA 中 SEO 的 RewriteRule 不起作用

Python + Django 在 apache2 (httpd)、Redhat 上的不同用户下运行

PHP Apc : how to view cache entries in APC

php - 通过 api 在 wordpress.com 中添加特色图片