Skip to content

Commit

Permalink
Fix: HTTP status code 100 Continue support" (#288)
Browse files Browse the repository at this point in the history
* Fix: HTTP Status Code `100 Continue` support

* Style: code style adjustment
  • Loading branch information
soarqin authored and Dreamacro committed Sep 8, 2019
1 parent 9875f8e commit 9815010
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions tunnel/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ func (t *Tunnel) handleHTTP(request *adapters.HTTPAdapter, outbound net.Conn) {
req := request.R
host := req.Host

inboundReeder := bufio.NewReader(request)
outboundReeder := bufio.NewReader(conn)

for {
keepAlive := strings.TrimSpace(strings.ToLower(req.Header.Get("Proxy-Connection"))) == "keep-alive"

Expand All @@ -27,8 +30,9 @@ func (t *Tunnel) handleHTTP(request *adapters.HTTPAdapter, outbound net.Conn) {
if err != nil {
break
}
br := bufio.NewReader(conn)
resp, err := http.ReadResponse(br, req)

handleResponse:
resp, err := http.ReadResponse(outboundReeder, req)
if err != nil {
break
}
Expand All @@ -50,7 +54,11 @@ func (t *Tunnel) handleHTTP(request *adapters.HTTPAdapter, outbound net.Conn) {
break
}

req, err = http.ReadRequest(bufio.NewReader(request))
if resp.StatusCode == http.StatusContinue {
goto handleResponse
}

req, err = http.ReadRequest(inboundReeder)
if err != nil {
break
}
Expand Down

0 comments on commit 9815010

Please sign in to comment.