Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
http: Status-Line with empty Reason-Phrase not supported #1388
Comments
Untested minimal fix, perhaps not fixing the root issue. (I'd prefer to fix readLine,
but that'd require some auditing)
bradfitz@bradfitz-glaptop:~/go/src$ hg diff
diff -r 51c777dbccb9 src/pkg/http/response.go
--- a/src/pkg/http/response.go Thu Dec 23 13:32:20 2010 +1100
+++ b/src/pkg/http/response.go Wed Jan 05 07:36:04 2011 -0800
@@ -86,9 +86,12 @@
return nil, err
}
f := strings.Split(line, " ", 3)
- if len(f) < 3 {
+ if len(f) < 2 {
return nil, &badStringError{"malformed HTTP response", line}
}
+ if len(f) == 2 {
+ f = append(f, "") // empty Reason-Phrase
+ }
resp.Status = f[1] + " " + f[2]
resp.StatusCode, err = strconv.Atoi(f[1])
if err != nil {
And the above patch doesn't properly reject responses like "HTTP/1.0 303" that don't end
in trailing whitespace.
|
I don't have a problem with accepting "HTTP/1.0 303\n".
Is it important to reject that? Liberal in what you accept and all.
I'd avoid the append by doing
text := ""
if len(f) > 2 {
text = f[2]
}
but otherwise sounds good to me.
Want to send it in?
Owner changed to r...@golang.org. Status changed to Accepted. |
|
This issue was closed by revision d71d08a. Status changed to Fixed. |
bradfitz
added
fixed
labels
Jan 5, 2011
bradfitz
assigned
rsc
Jan 5, 2011
gopherbot
locked and limited conversation to collaborators
Jun 24, 2016
gopherbot
added
the
FrozenDueToAge
label
Jun 24, 2016
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
bradfitz commentedJan 5, 2011