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

Don't panic if ResponseWriter does not implement CloseNotify #2651

Merged
merged 3 commits into from
Jan 4, 2018

Conversation

juliens
Copy link
Member

@juliens juliens commented Jan 3, 2018

What does this PR do?

Fix a panic in the retry middleware if the responseWriter does not implement CloseNotify. Happen with compress=true (Gzip does not implement CloseNotify yet)

Motivation

Fixes #2628

More

I think this is better that the next handler choose what to do if we don't implement CloseNotify instead of Panic or implement a wrong version of CloseNotify.

@juliens juliens added this to the 1.5 milestone Jan 3, 2018
@juliens juliens changed the title No panic if ResponseWriter does not implement CloseNotify Don't panic if ResponseWriter does not implement CloseNotify Jan 3, 2018
Copy link
Contributor

@nmengin nmengin left a comment

Choose a reason for hiding this comment

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

Nice catch @juliens !!

Only one little note about a comment, otherwise SGTM.

GetBody() *bytes.Buffer
IsStreamingResponseStarted() bool
}

// retryResponseRecorder is an implementation of http.ResponseWriter that
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be changed into retryResponseRecorderWithoutCloseNotify or moved above?

Copy link
Contributor

@nmengin nmengin left a comment

Choose a reason for hiding this comment

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

LGTM 👏

Copy link
Contributor

@ldez ldez left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@mmatur mmatur left a comment

Choose a reason for hiding this comment

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

LGTM 👏

@justb81
Copy link

justb81 commented Jan 24, 2018

i still see this in 1.5.0 final

24.1.2018 12:18:21time="2018-01-24T11:18:21Z" level=error msg="Recovered from panic in http handler: interface conversion: *negroni.responseWriter is not http.CloseNotifier: missing method CloseNotify"

if i disable http compression it is fine.

@juliens juliens deleted the close-notify-retry branch January 25, 2018 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants