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")
}
}
}
+// 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