Skip to content

Do not close client connection after returning HTTP status code 304 #963

Merged
mmatczuk merged 8 commits intomainfrom
mmt/304_hardening
Nov 21, 2024
Merged

Do not close client connection after returning HTTP status code 304 #963
mmatczuk merged 8 commits intomainfrom
mmt/304_hardening

Conversation

@mmatczuk
Copy link
Contributor

No description provided.

@mmatczuk mmatczuk requested a review from Choraden as a code owner November 20, 2024 14:34
if got, want := res.StatusCode, 304; got != want {
t.Fatalf("res.StatusCode: got %d, want %d", got, want)
}
if _, err := conn.Read(make([]byte, 0)); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's read at least a byte.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no byte, it would block, changing to nil.

@mmatczuk
Copy link
Contributor Author

Fixed implementations renamed some functions

…n extraction

The std http package returns the underlying connection in body of 101 response. The response body needs to be removed form the response.
Make reads from the replaced body panic to ensure that it's always handled correctly.
@mmatczuk mmatczuk merged commit 4d0dc65 into main Nov 21, 2024
@mmatczuk mmatczuk deleted the mmt/304_hardening branch November 21, 2024 13:50
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.

3 participants