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

use http.StatusOK as initial value for responseLogger.status #103

Merged
merged 1 commit into from
May 23, 2017

Conversation

damoye
Copy link
Contributor

@damoye damoye commented May 17, 2017

When handler never call w.WriteHeader or w.Write. LoggingHandler will print 0 as the status code. But client actually get 200.

After ServeHTTP finished, Go HTTP library will call WriteHeader(StatusOK) if wroteHeader is false.
Take a look at the function "finishRequest" in https://github.com/golang/go/blob/master/src/net/http/server.go

So, we should init responseLogger.status with http.StatusOK.

@kisielk
Copy link
Contributor

kisielk commented May 17, 2017

Looks good to me. Can you add a test so we can avoid regressions?

@damoye
Copy link
Contributor Author

damoye commented May 18, 2017

@kisielk OK. I just added a simple unit test for responseLogger.

@damoye
Copy link
Contributor Author

damoye commented May 23, 2017

@kisielk Is there any problem with this pull request?

@kisielk kisielk requested a review from elithrar May 23, 2017 15:34
@elithrar elithrar merged commit a4043c6 into gorilla:master May 23, 2017
@elithrar
Copy link
Contributor

Thanks @damoye!

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.

None yet

3 participants