-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
Description
51c777dbccb9 release.2010-12-22/release Go doesn't permit a HTTP response status line like: HTTP/1.0 303_ (where the "_" above is a trailing space, not an underscore) Unfortunately, App Engine's dev_appserver.py generates such responses. However, they appear to be valid: HTTP/1.1's definition: http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html#sec6.1 Status-Line = HTTP-Version SP Status-Code SP Reason-Phrase CRLF ... Reason-Phrase = *<TEXT, excluding CR, LF> Looking at Go's src/pkg/http/request.go and its readLineBytes() func, which is called by ReadResponse, the problem is that whitespace is stripped from the end before the split: func readLineBytes(b *bufio.Reader) (p []byte, err os.Error) { ... // Chop off trailing white space. var i int for i = len(p); i > 0; i-- { if c := p[i-1]; c != ' ' && c != '\r' && c != '\t' && c != '\n' { break } } return p[0:i], nil } func ReadResponse(r *bufio.Reader, requestMethod string) (resp *Response, err os.Error) { ... // Parse the first line of the response. line, err := readLine(r) ... f := strings.Split(line, " ", 3) if len(f) < 3 { return nil, &badStringError{"malformed HTTP response", line} }