Skip to content

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

Merged
elithrar merged 1 commit intogorilla:masterfrom
damoye:master
May 23, 2017
Merged

use http.StatusOK as initial value for responseLogger.status#103
elithrar merged 1 commit intogorilla:masterfrom
damoye:master

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.

3 participants