当前位置:   article > 正文

[问题记录] curl: (18) transfer closed with outstanding read data remaining 原因分析

transfer closed with outstanding read data remaining

问题描述

首先使用get方法请求apache的一个CGI,返回预期结果,然后换成post方法,结果返回如下错误:

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

错误的大致意思是:需要读取的数据还没有完成,但是传输数据的连接被关闭了。通过man curl也可以查到返回码18的错误描述,Partial file. Only a part of the file was transferred.


服务端CGI的代码很简单,只是构造了一个应答:

#!/bin/bash
echo "Content-type: text/html"
echo ""
echo $REQUEST_METHOD >> /tmp/somelog.gerry

# ok, we've sent the header, now send some content
echo  "{\"ret\":0,\"msg\":\"ok\"}"
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 客户端使用get方法调用(可以正常返回):
$curl -v "http://10.137.142.144/cgi-bin/test.sh?a=b&c=d"
* About to connect() to 10.137.142.144 port 80 (#0)
*   Trying 10.137.142.144... connected
* Connected to 10.137.142.144 (10.137.142.144) port 80 (#0)
> GET /cgi-bin/test.sh?a=b&c=d HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.13.1.0 zlib/1.2.3 libidn/1.18 libssh2/1.2.2
> Host: 10.137.142.144
> Accept: */*
> 
< HTTP/1.1 200 OK
< Date: Fri, 08 Apr 2016 05:49:48 GMT
< Server: Apache/2.4.2 (Unix)
< Transfer-Encoding: chunked
< Content-Type: text/html
< 
{
  "ret":0,"msg":"ok"}
* Connection #0 to host 10.137.142.144 left intact
* Closing connection #0
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 客户端使用post方法调用(出现curl: (18)错误):
$curl -v -d"a=b&c=d" http://10.137.142.144/cgi-bin/test.sh            
* About to connect() to 10.137.142.144 port 80 (#0)
*   Trying 10.137.142.144... connected
* Connected to 10.137.142.144 (10.137.142.144) port 80 (#0)
> POST /cgi-bin/test.sh HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.13.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Cpp五条/article/detail/707555?site
推荐阅读
相关标签
  

闽ICP备14008679号