"Content-Length: 6\r\n\r\n" +
"abcdef",
},
+ // Unchunked response without Content-Length.
+ respWriteTest{
+ Response{
+ StatusCode: 200,
+ ProtoMajor: 1,
+ ProtoMinor: 0,
+ RequestMethod: "GET",
+ Header: map[string]string{},
+ Body: nopCloser{bytes.NewBufferString("abcdef")},
+ ContentLength: -1,
+ },
+ "HTTP/1.0 200 OK\r\n" +
+ "\r\n" +
+ "abcdef",
+ },
// HTTP/1.1, chunked coding; empty trailer; close
respWriteTest{
Response{
if err == nil {
err = cw.Close()
}
+ } else if t.ContentLength == -1 {
+ _, err = io.Copy(w, t.Body)
} else {
_, err = io.Copy(w, io.LimitReader(t.Body, t.ContentLength))
}