From 37666561b2f040c965aa8d635453f2e58839e7bc Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 24 Feb 2010 15:13:39 -0800 Subject: http: fix handling of Close, use Close in http.Post default to HTTP/1.1 R=petar-m CC=golang-dev https://golang.org/cl/224041 --- src/pkg/http/requestwrite_test.go | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'src/pkg/http/requestwrite_test.go') diff --git a/src/pkg/http/requestwrite_test.go b/src/pkg/http/requestwrite_test.go index 2b47e0b3b1..f39e8a86d5 100644 --- a/src/pkg/http/requestwrite_test.go +++ b/src/pkg/http/requestwrite_test.go @@ -82,6 +82,43 @@ var reqWriteTests = []reqWriteTest{ "Transfer-Encoding: chunked\r\n\r\n" + "6\r\nabcdef\r\n0\r\n\r\n", }, + // HTTP/1.1 POST => chunked coding; body; empty trailer + reqWriteTest{ + Request{ + Method: "POST", + URL: &URL{ + Scheme: "http", + Host: "www.google.com", + Path: "/search", + }, + ProtoMajor: 1, + ProtoMinor: 1, + Header: map[string]string{}, + Close: true, + Body: nopCloser{bytes.NewBufferString("abcdef")}, + TransferEncoding: []string{"chunked"}, + }, + + "POST /search HTTP/1.1\r\n" + + "Host: www.google.com\r\n" + + "User-Agent: Go http package\r\n" + + "Connection: close\r\n" + + "Transfer-Encoding: chunked\r\n\r\n" + + "6\r\nabcdef\r\n0\r\n\r\n", + }, + // default to HTTP/1.1 + reqWriteTest{ + Request{ + Method: "GET", + RawURL: "/search", + Host: "www.google.com", + }, + + "GET /search HTTP/1.1\r\n" + + "Host: www.google.com\r\n" + + "User-Agent: Go http package\r\n" + + "\r\n", + }, } func TestRequestWrite(t *testing.T) { -- cgit v1.3-5-g9baa