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

run: always set content length #24

Merged
merged 2 commits into from
Apr 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions cli/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,9 @@ func invoke(ctx context.Context, client *http.Client, url, requestID string, bri
if endpointReq.ContentLength > 0 {
endpointReqBody.Grow(int(endpointReq.ContentLength))
}
_, err = io.Copy(endpointReqBody, endpointReq.Body)
bridgeGetRes.Body.Close()
endpointReq.ContentLength, err = io.Copy(endpointReqBody, endpointReq.Body)
endpointReq.Body.Close()
bridgeGetRes.Body.Close()
if err != nil {
return fmt.Errorf("failed to read response from Dispatch API: %v", err)
}
Expand Down Expand Up @@ -379,6 +379,7 @@ func invoke(ctx context.Context, client *http.Client, url, requestID string, bri
return fmt.Errorf("failed to read response from local application endpoint (%s): %v", LocalEndpoint, err)
}
endpointRes.Body = io.NopCloser(endpointResBody)
endpointRes.ContentLength = int64(endpointResBody.Len())

// Parse the response body from the API.
if endpointRes.StatusCode == http.StatusOK && endpointRes.Header.Get("Content-Type") == "application/proto" {
Expand Down
Loading