-
Notifications
You must be signed in to change notification settings - Fork 238
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
embedded:network/http/client hangs if server sends no response body #1219
Comments
HTTP 204 is a special case where the response body is always empty. The usual Content-Length field is not included with a 0 because the status implies it. I think HTTP 205 is the same. Changing these lines in httpclient.js... moddable/examples/io/tcp/httpclient/httpclient.js Lines 251 to 261 in c5845e5
...to the following, gives the expected result. if ((204 === this.#status) || (205 === this.#status))
this.#remaining = 0;
else if (undefined !== this.#chunk)
this.#remaining = undefined; // ignore content-length if chunked
else if (undefined === this.#remaining)
this.#remaining = Infinity;
this.#current.onHeaders?.call(this.#current.request, this.#status, this.#headers);
if (!this.#current) return; // closed in callback
this.#headers = undefined;
this.#state = "receiveBody";
this.#line = (undefined == this.#chunk) ? undefined : "";
if (0 === this.#remaining)
return void this.#done(); It looks like this might also help with the case where "Content-Length" is Does that work for you as well? |
Fix committed. Closing. (If problem persists, please reopen.) |
Build environment: Linux
Moddable SDK version: idf-v5
Target device: esp32-c3
Description
If the server response does not include a response body then the client hangs after the onHeaders callback. There is no onDone callback and subsequent requests are never processed. A typical case is a POST that results in a 204 "No Content" status.
Steps to Reproduce
examples/io/tcp/httpclient
:Expected behavior
I expected to see
**DONE 1 **
immediately and I expected the third request to succeed.The text was updated successfully, but these errors were encountered: