Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions readrequest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ var reqTests = []reqTest{
":path": {"/"},
":host": {"www.techcrunch.com"},
":version": {"HTTP/1.1"},
":query": {""},
"User-Agent": {"Fake"},
"Accept": {"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"},
"Accept-Language": {"en-us,en;q=0.5"},
Expand All @@ -53,6 +54,7 @@ var reqTests = []reqTest{
Scheme: "http",
Host: "www.techcrunch.com",
Path: "/",
RawQuery: "",
},
Proto: "HTTP/1.1",
ProtoMajor: 1,
Expand Down Expand Up @@ -87,6 +89,7 @@ var reqTests = []reqTest{
":path": {"/"},
":host": {"foo.com"},
":version": {"HTTP/1.1"},
":query": {""},
},
noBody,
noTrailer,
Expand Down Expand Up @@ -121,6 +124,7 @@ var reqTests = []reqTest{
":path": {"../../../../etc/passwd"},
":host": {"test"},
":version": {"HTTP/1.1"},
":query": {""},
},
noBody,
noTrailer,
Expand All @@ -137,6 +141,7 @@ var reqTests = []reqTest{
":method": {"GET"},
":host": {"test"},
":version": {"HTTP/1.1"},
":query": {""},
},
noBody,
noTrailer,
Expand All @@ -154,6 +159,7 @@ var reqTests = []reqTest{
":path": {"/"},
":host": {"foo.com"},
":version": {"HTTP/1.1"},
":query": {""},
},
"foobar",
http.Header{
Expand Down Expand Up @@ -191,6 +197,7 @@ var reqTests = []reqTest{
":path": {"/"},
":host": {"www.google.com:443"},
":version": {"HTTP/1.1"},
":query": {""},
},
noBody,
noTrailer,
Expand Down Expand Up @@ -225,6 +232,7 @@ var reqTests = []reqTest{
":path": {"/"},
":host": {"127.0.0.1:6060"},
":version": {"HTTP/1.1"},
":query": {""},
},
noBody,
noTrailer,
Expand Down Expand Up @@ -259,6 +267,7 @@ var reqTests = []reqTest{
":path": {"/_goRPC_"},
":host": {""},
":version": {"HTTP/1.1"},
":query": {""},
},
noBody,
noTrailer,
Expand Down
8 changes: 5 additions & 3 deletions request.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ func ReadRequest(h, t http.Header, r io.Reader) (*http.Request, error) {
return nil, errors.New("invalid path: " + path)
}
req.URL = &url.URL{
Scheme: h.Get(":scheme"),
Path: path,
Host: h.Get(":host"),
Scheme: h.Get(":scheme"),
Path: path,
Host: h.Get(":host"),
RawQuery: h.Get(":query"),
}
req.Close = true
req.Method = h.Get(":method")
Expand Down Expand Up @@ -76,5 +77,6 @@ func RequestFramingHeader(r *http.Request) http.Header {
h.Set(":method", r.Method)
h.Set(":path", r.URL.Path)
h.Set(":version", r.Proto)
h.Set(":query", r.URL.RawQuery)
return h
}