【问题标题】:CURL json output cuts offCURL json输出切断
【发布时间】:2019-05-24 03:46:47
【问题描述】:

我正在使用 centos 7 并且有这个 json 请求:

curl  --output 'json.data.json' -vvv -x ''  -X POST -H "Content-Type: application/json" -H "Connection: keep-alive" -d '{"jsonrpc":"2.0","method":"item.get","params":{"output": ["name","lastvalue","lastclock","hostid"],"groupids": ["5"],"filter":{"name":["LDT Security Flag"]},"sortfield": "name" },"auth":"c1cxxxxxxxxx","id":1}' $CURLADDR 

现在, 在我看到的结果中间:

734247","lastvalue":"0"},{"itemid":"192890","name":"LDT Fl* transfer closed with outstanding read data remaining
100 86797    0 86569  100   228  75094    197  0:00:01  0:00:01 --:--:-- 75146
* Closing connection 0
curl: (18) transfer closed with outstanding read data remaining

然后还有一些 json 结果。 但我注意到,无论我运行它多少次并将输出重定向到 .json 文件,文件总是以相同的大小:88K 就像信息下载大小有某种限制?我该怎么办?

更新:

所以我添加了它,现在错误:curl: (18) 传输已关闭,剩余未完成的读取数据消失了。但仍然在中间切开:* Closing Connection 0,文件为 88K – Batchen Regev 11 分钟前

还有连接数据:

> POST /api_jsonrpc.php HTTP/1.0
> User-Agent: curl/7.29.0
> Host: XXXXXX:1080
> Content-Type: application/json;charset=utf-8
> Accept: application/json, text/plain, */*
> Content-Length: 224
>
} [data not shown]
* upload completely sent off: 224 out of 224 bytes
100   224    0     0  100   224      0    223  0:00:01  0:00:01 --:--:--   223< HTTP/1.1 200 OK
< Server: nginx
< Date: Tue, 25 Dec 2018 15:21:07 GMT
< Content-Type: application/json
< Connection: close
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Headers: Content-Type
< Access-Control-Allow-Methods: POST
< Access-Control-Max-Age: 1000
<
{ [data not shown]
100 86840    0 86616  100   224  77583    200  0:00:01  0:00:01 --:--:-- 77612
* Closing connection 0

【问题讨论】:

    标签: json bash curl output jq


    【解决方案1】:

    这似乎是服务器端问题。 您可以尝试通过使用 --http1.0 选项强制 HTTP 1.0 连接(以避免可能导致此问题的分块传输)来解决此问题。

    【讨论】:

    • 嘿,所以我添加了它,现在错误:curl: (18) transfer closed with outstanding read data remaining 消失了。但仍然在中间切开:` * Closing connection 0 ` and file is 88K
    • 你可以试试 Postman 之类的其他工具,看看是否会发生同样的事情。
    • 我已经尝试过 YARC,但它并没有在那里切断。这就是为什么我认为它与 CURL 有点关系,但不知道是什么。我知道信息非常大,也许这就是为什么..但我该如何克服呢?
    【解决方案2】:

    CURLE_PARTIAL_FILE (18)

    文件传输比预期短或大。当服务器首先报告预期的传输大小,然后交付与先前给定大小不匹配的数据时,就会发生这种情况。

    来源:https://curl.haxx.se/libcurl/c/libcurl-errors.html

    【讨论】:

    • 嘿,我添加了建议的 --http1.0 选项,错误 18 消失了,但我进入 CURL 中间,仍然数据被切断。还有什么想法吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-09-17
    • 2019-04-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-06
    • 2015-10-27
    相关资源
    最近更新 更多