curl error 18: transfer closed with outstanding read data remaining
curl HTTP 大约 1463 字现象
curl
发起请求时,请求体中包含了最后第二行错误信息。
❯ curl -vv -s -o /dev/null http://localhost:8081/test
* Trying 127.0.0.1:8081...
* Connected to localhost (127.0.0.1) port 8081 (#0)
> GET /test HTTP/1.1
> Host: localhost:8081
> User-Agent: curl/7.88.1
> Accept: */*
>
< HTTP/1.1 200
< X-Content-Type-Options: nosniff
< X-XSS-Protection: 1; mode=block
< Cache-Control: no-cache, no-store, max-age=0, must-revalidate
< Pragma: no-cache
< Expires: 0
< X-Frame-Options: DENY
< Content-Type: application/json
< Transfer-Encoding: chunked
< Date: Thu, 29 Jun 2023 05:59:30 GMT
<
{ [7862 bytes data]
* transfer closed with outstanding read data remaining
* Closing connection 0
原因
我们使用了HTTP/1.1
协议,默认的Transfer-Encoding
是chunked
,而curl
认为最后的chunked
没有被完整的接收。
也可以认为Content-Length
解决
需要服务端解决此问题。
http/1.0
也可以使用http/1.0
的方式。(不推荐)
❯ curl --http1.0 -vv -s -o /dev/null http://localhost:8081/test
* Trying 127.0.0.1:8081...
* Connected to localhost (127.0.0.1) port 8081 (#0)
> GET /test HTTP/1.0
> Host: localhost:8081
> User-Agent: curl/7.88.1
> Accept: */*
>
< HTTP/1.1 200
< X-Content-Type-Options: nosniff
< X-XSS-Protection: 1; mode=block
< Cache-Control: no-cache, no-store, max-age=0, must-revalidate
< Pragma: no-cache
< Expires: 0
< X-Frame-Options: DENY
< Content-Type: application/json
< Date: Thu, 29 Jun 2023 06:04:21 GMT
< Connection: close
<
{ [7871 bytes data]
* Closing connection 0
阅读 103 · 发布于 2023-08-31
————        END        ————
Give me a Star, Thanks:)
https://github.com/fendoudebb扫描下方二维码关注公众号和小程序↓↓↓

昵称:
随便看看
换一批
-
Go 中的 GOROOT 和 GOPATH阅读 4288
-
MySQL Explain 中的 key_len阅读 1539
-
Spring Boot 3.2 RestClient 同步 HTTP 客户端阅读 129
-
Rust 动态大小类型阅读 214
-
Windows 动态端口阅读 735
-
Linux 编译安装 PostgreSQL阅读 1723
-
OpenResty 整合 LuaRocks - Linux阅读 2660
-
Docker springci 编译 Spring Navtive 工程为 Linux 可执行文件阅读 640
-
Java 语法糖 - 方法重写时的桥接方法阅读 930
-
pgAdmin4 Failed to open the system default web browser.Is one installed?.阅读 9262