Browse Source

fix for handling responses with no body

Alan Shreve 11 years ago
parent
commit
b6f7258686
1 changed files with 6 additions and 3 deletions
  1. 6 3
      src/ngrok/proto/http.go

+ 6 - 3
src/ngrok/proto/http.go

@@ -111,9 +111,12 @@ func (h *Http) readResponses(tee *conn.Tee, lastTxn chan *HttpTxn) {
 		_, _ = httputil.DumpResponse(resp, true)
 		_, _ = httputil.DumpResponse(resp, true)
 
 
 		txn.Resp = &HttpResponse{Response: resp}
 		txn.Resp = &HttpResponse{Response: resp}
-		txn.Resp.BodyBytes, txn.Resp.Body, err = extractBody(resp.Body)
-		if err != nil {
-			tee.Warn("Failed to extract response body: %v", err)
+		// apparently, Body can be nil in some cases
+		if resp.Body != nil {
+			txn.Resp.BodyBytes, txn.Resp.Body, err = extractBody(resp.Body)
+			if err != nil {
+				tee.Warn("Failed to extract response body: %v", err)
+			}
 		}
 		}
 
 
 		h.Txns.In() <- txn
 		h.Txns.In() <- txn