Skip to content

Commit

Permalink
fix crash when there is no body.
Browse files Browse the repository at this point in the history
  • Loading branch information
inconshreveable committed Nov 13, 2014
1 parent d5c42b1 commit d79f119
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/ngrok/proto/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package proto
import (
"bufio"
"bytes"
metrics "github.com/rcrowley/go-metrics"
"io"
"io/ioutil"
"net"
Expand All @@ -15,6 +14,8 @@ import (
"strings"
"sync"
"time"

metrics "github.com/rcrowley/go-metrics"
)

type HttpRequest struct {
Expand Down Expand Up @@ -93,7 +94,12 @@ func (h *Http) readRequests(tee *conn.Tee, lastTxn chan *HttpTxn, connCtx interf

txn := &HttpTxn{Start: time.Now(), ConnUserCtx: connCtx}
txn.Req = &HttpRequest{Request: req}
txn.Req.BodyBytes, txn.Req.Body, err = extractBody(req.Body)
if req.Body != nil {
txn.Req.BodyBytes, txn.Req.Body, err = extractBody(req.Body)
if err != nil {
tee.Warn("Failed to extract request body: %v", err)
}
}

lastTxn <- txn
h.Txns.In() <- txn
Expand Down

0 comments on commit d79f119

Please sign in to comment.