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

InvalidInput when decoding manifest due to HTTP 1.1 call #131

Closed
sschueller opened this issue Jun 17, 2023 · 1 comment
Closed

InvalidInput when decoding manifest due to HTTP 1.1 call #131

sschueller opened this issue Jun 17, 2023 · 1 comment

Comments

@sschueller
Copy link
Contributor

sschueller commented Jun 17, 2023

  • Arduino board: esp32-s3-devkitc-1

  • Arduino IDE version (found in Arduino -> About Arduino menu): Platform IO Core 6.1.7

  • List the steps to reproduce the problem below (if possible attach a sketch or
    copy the sketch code in too):

Returning the json manifest from my web server running a fairly new nginx version I get "InvalidInput" when decoding the json with a length of -1.

This appears to be due to https://arduinojson.org/v6/how-to/use-arduinojson-with-httpclient/#how-to-parse-a-json-document-from-an-http-response

"Unfortunately, by using the underlying Stream, we bypass the code that handles chunked transfer encoding, so we must switch to HTTP version 1.0."

Sniffing the traffic, the response is indeed "HTTP 1.1" and _http.getStream() returns empty while _http.getString() does not.

When I add _http.useHTTP10(true); as mentioned in the arduniojson docs before the _http.GET(), the call is "HTTP 1.0" and the manifest can be decoded. However this does disable chunked transfers.

Can _http.useHTTP10(true); be added for calls to the manifest? Alternatively one could use the _http.getString(); but this is only ok for very small jsons.

@sschueller
Copy link
Contributor Author

Here is a work around for anyone wanting to use Symphony php framework to serve the updates:

In your Controller:

// remove chunked to support arduino http 1.0 
$response = (new JsonResponse(json_encode($listOfFirmwaresArray, (JSON_UNESCAPED_SLASHES)), 200, [], true));
$response->headers->remove('Transfer-Encoding');
$response->headers->set('Content-Length', strlen($response->getContent()));
return $response;

@tobozo tobozo closed this as completed in a0cd3da Aug 19, 2024
tobozo added a commit that referenced this issue Aug 19, 2024
Added config option to force http 1.0, fixes #131
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