从我的linux机器运行curl POST命令时,我遇到了一个问题。
错误信息如下 - 卷曲:(18)转移关闭,剩余未完成的读取数据
我可以在其他方案中成功发布数据,例如拆分文件中的数据并多次执行此操作。 运行curl命令后我得到的完整响应如下所示
curl -X POST --data @dataCurl -ik -u userid:password -H 'Accept: application/xml' https://IP_ADDRESS:PORT/rest/xxx/xx/
HTTP/1.1 100 Continue
Content-Length: 0
Date: Tue, 26 Mar 2013 14:54:32 GMT
Server: WebSphere Application Server/6.1
HTTP/1.1 400 Bad Request
Date: Tue, 26 Mar 2013 14:54:32 GMT
Server: WebSphere Application Server/6.1
Content-Type: text/html;charset=ISO-8859-1
$WSEP:
Content-Language: en-US
Set-Cookie: LtpaToken2=SaVGscL3xKqJoTFymznYPqJKBuPO5HBhrpSTg2c+cpknypCODPb2r3RzJy7bP7kxoIWWUVS3iAlxIr0WLv5bhW1r2a3nW0i26Iblnlm07Xf
Set-Cookie: LtpaToken=azPyTXehorPwNejA+UFxlrs+7yQfxQoQws/tXc97yQ5IWjykBjIejbp/2cVAHP5CCI01PnrK+TgZq3+C3HM8jc6GovZ9ID+TwjnDZHSvCgOjEk7lZRX2Sqyk49gGE5BMAZaTRJOF5mK0UNCELWG57KunZbSmqOis3h1F5phKOm2duQDqvRf3C54HTLrH60ec1YwMwXVUU9mAECgLIJIZC/2+shzjkn+2zAF3kgN5sDDVvFyO1aCnJje0VcdRosbIqGQgB01sBm4RXqXRtI3RbiHL9ThtHWH62xQwvVh9UYEphK/XY1Zk3vclRX2IFmDqNG8nsR7zIyY=; Path=/
Set-Cookie: JSESSIONID=0000EJSJpUPd0JIBOZcOEZ_oyiC:-1; Path=/
Transfer-Encoding: chunked
Connection: Close
Expires: Thu, 01 Dec 1994 16:00:00 GMT
Cache-Control: no-cache="set-cookie, set-cookie2"
curl: (18) transfer closed with outstanding read data remaining
如果我将数据文件拆分成较小的块,我可以POST数据。该实例的响应如下
curl -X POST --data @SRPart1 -ik -u userid:password -H 'Accept: application/xml' https://IP_ADDRESS:PORT/rest/xxx/xx/
HTTP/1.1 200 OK
Content-Type: application/xml
Expires: -1
Content-Language: en-US
Set-Cookie:
LtpaToken2=I+Gw+zcgPZDCpUWhKIfr53IiOulhfU5gH1rLIzQi9jdpSLASBkCirkle4qDRnkk+1teEkcN/bHq+Amv4BKrK+9xNy4B6RdWPH0O9S2vfnAC5RqmuoSCFwqWXzTINoWGYH+TqqL24KvjhXOWQ43E
有没有办法解决这个问题?
答案 0 :(得分:1)
我想出了一个解决方案,这可能对未来的人有用或可能没用。
我使用awk函数和for循环将我的输入文件分成几个部分然后运行curl命令来解决这个问题。
awk '
BEGIN{ fn = "xxx"; n = 1}
{
print > fn
if (match($0,"YYYID")) {
close (fn)
n++
fn = "xxx" n
}
}' inputfile
for j in xxx*
do
{
curl -X POST --data @$j -ik -u userid:password -H 'Accept: applicatin/xml' https://IPADDRESS/rest/XXX/XX/
} done