0

从我的 linux 机器运行 curl POST 命令时遇到问题。

错误信息如下 - curl: (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

如果我将数据文件分成更小的块,我可以发布数据。该实例的响应如下

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

有没有办法来解决这个问题 ?

4

1 回答 1

1

I came up with an work around, this may or may not be useful for someone in future.

I used awk function and for loop to break my input file into several pieces and then ran curl command to solve this issue.

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
于 2013-04-02T13:23:24.440 回答