aboutsummaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
Diffstat (limited to 'src/net')
-rw-r--r--src/net/http/cgi/child.go7
-rw-r--r--src/net/http/cgi/child_test.go22
-rw-r--r--src/net/http/http.go4
-rw-r--r--src/net/http/netconn_test.go3
-rw-r--r--src/net/http/pattern.go8
-rw-r--r--src/net/http/transport.go2
6 files changed, 29 insertions, 17 deletions
diff --git a/src/net/http/cgi/child.go b/src/net/http/cgi/child.go
index e29fe20d7d..466d42c08e 100644
--- a/src/net/http/cgi/child.go
+++ b/src/net/http/cgi/child.go
@@ -57,8 +57,11 @@ func RequestFromMap(params map[string]string) (*http.Request, error) {
r.Proto = params["SERVER_PROTOCOL"]
var ok bool
- r.ProtoMajor, r.ProtoMinor, ok = http.ParseHTTPVersion(r.Proto)
- if !ok {
+ if r.Proto == "INCLUDED" {
+ // SSI (Server Side Include) use case
+ // CGI Specification RFC 3875 - section 4.1.16
+ r.ProtoMajor, r.ProtoMinor = 1, 0
+ } else if r.ProtoMajor, r.ProtoMinor, ok = http.ParseHTTPVersion(r.Proto); !ok {
return nil, errors.New("cgi: invalid SERVER_PROTOCOL version")
}
diff --git a/src/net/http/cgi/child_test.go b/src/net/http/cgi/child_test.go
index 18cf789bd5..f901bec1a8 100644
--- a/src/net/http/cgi/child_test.go
+++ b/src/net/http/cgi/child_test.go
@@ -154,6 +154,28 @@ func TestRequestWithoutRemotePort(t *testing.T) {
}
}
+// CGI Specification RFC 3875 - section 4.1.16
+// INCLUDED value for SERVER_PROTOCOL must be treated as an HTTP/1.0 request
+func TestIncludedServerProtocol(t *testing.T) {
+ env := map[string]string{
+ "REQUEST_METHOD": "GET",
+ "SERVER_PROTOCOL": "INCLUDED",
+ }
+ req, err := RequestFromMap(env)
+ if req.Proto != "INCLUDED" {
+ t.Errorf("unexpected change to SERVER_PROTOCOL")
+ }
+ if major := req.ProtoMajor; major != 1 {
+ t.Errorf("ProtoMajor: got %d, want %d", major, 1)
+ }
+ if minor := req.ProtoMinor; minor != 0 {
+ t.Errorf("ProtoMinor: got %d, want %d", minor, 0)
+ }
+ if err != nil {
+ t.Fatalf("expected INCLUDED to be treated as HTTP/1.0 request")
+ }
+}
+
func TestResponse(t *testing.T) {
var tests = []struct {
name string
diff --git a/src/net/http/http.go b/src/net/http/http.go
index e7959fa3b6..d346e60646 100644
--- a/src/net/http/http.go
+++ b/src/net/http/http.go
@@ -119,10 +119,6 @@ func removeEmptyPort(host string) string {
return host
}
-func isNotToken(r rune) bool {
- return !httpguts.IsTokenRune(r)
-}
-
// isToken reports whether v is a valid token (https://www.rfc-editor.org/rfc/rfc2616#section-2.2).
func isToken(v string) bool {
// For historical reasons, this function is called ValidHeaderFieldName (see issue #67031).
diff --git a/src/net/http/netconn_test.go b/src/net/http/netconn_test.go
index 52b8069f8b..c5fd61289f 100644
--- a/src/net/http/netconn_test.go
+++ b/src/net/http/netconn_test.go
@@ -180,9 +180,10 @@ func (c *fakeNetConn) Close() error {
c.loc.unlock()
// Remote half of the connection reads EOF after reading any remaining data.
c.rem.lock()
- if c.rem.readErr != nil {
+ if c.rem.readErr == nil {
c.rem.readErr = io.EOF
}
+ c.rem.writeErr = net.ErrClosed
c.rem.unlock()
if c.autoWait {
synctest.Wait()
diff --git a/src/net/http/pattern.go b/src/net/http/pattern.go
index 8fd120e777..a5063807c6 100644
--- a/src/net/http/pattern.go
+++ b/src/net/http/pattern.go
@@ -394,14 +394,6 @@ func inverseRelationship(r relationship) relationship {
}
}
-// isLitOrSingle reports whether the segment is a non-dollar literal or a single wildcard.
-func isLitOrSingle(seg segment) bool {
- if seg.wild {
- return !seg.multi
- }
- return seg.s != "/"
-}
-
// describeConflict returns an explanation of why two patterns conflict.
func describeConflict(p1, p2 *pattern) string {
mrel := p1.compareMethods(p2)
diff --git a/src/net/http/transport.go b/src/net/http/transport.go
index a560765d33..4e6b07f34d 100644
--- a/src/net/http/transport.go
+++ b/src/net/http/transport.go
@@ -2110,7 +2110,6 @@ type persistConn struct {
numExpectedResponses int
closed error // set non-nil when conn is closed, before closech is closed
canceledErr error // set non-nil if conn is canceled
- broken bool // an error has happened on this connection; marked broken so it's not reused.
reused bool // whether conn has had successful request/response and is being reused.
// mutateHeaderFunc is an optional func to modify extra
// headers on each outbound request before it's written. (the
@@ -2925,7 +2924,6 @@ func (pc *persistConn) closeLocked(err error) {
if err == nil {
panic("nil error")
}
- pc.broken = true
if pc.closed == nil {
pc.closed = err
pc.t.decConnsPerHost(pc.cacheKey)