qri-io / starlib

qri's standard library for starlark
MIT License
113 stars 29 forks source link

Ensure Content-Length is Sent #170

Closed Matt-Pesce closed 2 years ago

Matt-Pesce commented 2 years ago

Added specification of Content-Length during creation of the Request Body for URL Encoded and JSON Encoded content.

The existing implementation uses the ioutil.NopCloser method to create the Request body, which triggers ShouldSendChunkedRequestBody in https://go.dev/src/net/http/transfer.go that results in the Request Header specifying Transfer-Encoding: Chunked.

This change enables compatibility with Endpoints (such as Microsoft Graph APIs) that do not support Transfer-Encoding: Chunked

Testing: I've rebuilt the new http.go library into the Pixlet application: https://github.com/tidbyt/pixlet and hit multiple endpoints at Google and MSFT cloud with successful result (about 10 different API calls)

betterengineering commented 2 years ago

cc @dustmop @b5 can you take a look?