[问题记录] curl: (18) 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\"}"
  • 客户端使用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
  • 客户端使用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.
  • 4
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值