Skip to content

dataplane: close HTTP response body in relayWrite - #344

Open
Arjun Mehta (Arjunmehta312) wants to merge 1 commit into
microsoft:mainfrom
Arjunmehta312:fix/relaywrite-body-close
Open

dataplane: close HTTP response body in relayWrite#344
Arjun Mehta (Arjunmehta312) wants to merge 1 commit into
microsoft:mainfrom
Arjunmehta312:fix/relaywrite-body-close

Conversation

@Arjunmehta312

Copy link
Copy Markdown

Fixes a resource leak in relayWrite() where HTTP response bodies were drained but never closed.

Bug: relayWrite() calls io.Copy(io.Discard, resp.Body) after the relay request, but did not close the response body afterward. This can prevent proper HTTP connection reuse and leak response-body resources.

Fix: Close resp.Body after draining it, following the existing response-body handling patterns in readRelay(), pingRelay(), and ContainerClient.Do().

Test: Added TestRelayWriteClosesResponseBody, which uses a tracking response body to verify that the PUT response body is closed.

Validation:

  • go test ./...
  • Focused dataplane tests
  • gofmt
  • git diff --check

Scope: Small, targeted lifecycle fix with no changes to retry, error-handling, or metrics behavior.

@Arjunmehta312

Copy link
Copy Markdown
Author

John Stairs (@johnstairs) Hi
Please review when you can.
Excited to contribute :)
Thank you so much!

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

Successfully merging this pull request may close these issues.

1 participant