-
Notifications
You must be signed in to change notification settings - Fork 472
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
Send errors instead of 100 Continue... #377
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice work, thanks! Got some feedback for you.
@@ -915,15 +915,8 @@ func (handler *UnroutedHandler) sendError(w http.ResponseWriter, r *http.Request | |||
statusErr = NewHTTPError(err, http.StatusInternalServerError) | |||
} | |||
|
|||
reason := append(statusErr.Body(), '\n') | |||
if r.Method == "HEAD" { | |||
reason = nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know how http.Error
handles HEAD requests? Does it include the body or not?
if r.Method == "HEAD" { | ||
reason = nil | ||
} | ||
|
||
w.Header().Set("Content-Type", "text/plain; charset=utf-8") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The http.Error
method automatically sets the same Content-Type header, so could remove this here. See https://golang.org/src/net/http/server.go?s=62104:62156#L2011
Also, please have a look at the failing tests: https://github.com/tus/tusd/runs/604523101 |
I actually can't reproduce the problem now, I think I must have been testing through nginx in our dev env and getting tricked by their hardcoded 100-continue support!
If you have a chance though, could you please take a look over my other 2 PRs? Would be great to get those upstreamed and not have to maintain a fork! |
👍 Thanks a lot for your efforts! I will have a look at your other PRs as soon as possible. |
... when requests have the
Expect: 100-continue
header.Go's HTTP server automatically returns
100 Continue
if the Expect header is there, unless you use thehttp.Error()
method.Also handles the content length and body automagically.