Skip to content

HTTPS Client is not compliant with HTTP 1.1 #10

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

Open
gregjesl opened this issue Aug 29, 2018 · 0 comments
Open

HTTPS Client is not compliant with HTTP 1.1 #10

gregjesl opened this issue Aug 29, 2018 · 0 comments

Comments

@gregjesl
Copy link

We've been using your example with great success for a while but have recently run into an issue with file downloads. After digging in to the issue, it turns out the https_client used in this example is not compliant with HTTP 1.1.

Per the HTTP 1.1 spec:

All HTTP/1.1 applications MUST be able to receive and decode the "chunked" transfer-coding, and MUST ignore chunk-extension extensions they do not understand.

When a response is chunked, no Content-Length header is sent (see here for more details); however, the HTTPS client will fail if the Content-Length header is not set in the response:

// We're mainly interested in the content length.
// The server should either send the Content-Length header or should close the connection at the end.
int contentLength = 0;
if (!http_parse_key_value_int(httpRequest->response_buffer, "Content-Length:", &contentLength)) {
ESP_LOGD(TAG, "Content-Length: %d", contentLength);
httpContext->content_length = contentLength;
} else {
ESP_LOGW(TAG, "Content length header missing, dropping the packet. '%s'", httpRequest->response_buffer);
// TODO error callback??
return 0;
}

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

1 participant