Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http_client_send_async返回状态正常,但是body偶尔为空的问题 #680

Open
LOUTINIER opened this issue Feb 12, 2025 · 4 comments

Comments

@LOUTINIER
Copy link

http_client_send_async(req, [=](const HttpResponsePtr &resp) {
if (resp != nullptr)
        {
            resp->body; //body=""
            resp->status_code; // status_code=200
        }
        else
        {
        }
}

有没有人遇到这种情况,发生这种情况时服务端并未收到这条请求,但是libhv确实返回了200以及空body

@ithewei
Copy link
Owner

ithewei commented Feb 18, 2025

resp->Dump(true, false),打印下整个响应头看看

@LOUTINIER
Copy link
Author

空body的头dump出来是这样的

HTTP/1.1 200 OK
Content-Length: 0
Date: Tue, 18 Feb 2025 03:58:28 GMT

正常的是这样的

HTTP/1.1 200 OK
Access-Control-Allow-Headers: *
Access-Control-Allow-Methods: *
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: *
Access-Control-Max-Age: 5
Connection: keep-alive
Content-Type: text/json;charset=UTF-8
Date: Tue, 18 Feb 2025 03:58:17 GMT
Server: APISIX/3.10.0
Transfer-Encoding: chunked
Vary: Accept-Encoding
X-Powered-By: AtomCode v3.3.2
X-Request-Id: 14af424c-b36a-4fee-a81b-47dcce23b1b9

@ithewei
Copy link
Owner

ithewei commented Feb 18, 2025

成功回调最终是调用这里,上面是有判断解析器状态的,

ctx->successCallback();

你可以加点日志看看

@LOUTINIER
Copy link
Author

好,近期没空,后面再看看

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants