diff --git a/flow/encoding.go b/flow/encoding.go index 03f72ad..f185f69 100644 --- a/flow/encoding.go +++ b/flow/encoding.go @@ -6,6 +6,8 @@ import ( "errors" "io" "strings" + + "github.com/andybalholm/brotli" ) // handle http header: content-encoding @@ -89,6 +91,14 @@ func Decode(enc string, body []byte) ([]byte, error) { return nil, err } return buf.Bytes(), nil + } else if enc == "br" { + brr := brotli.NewReader(bytes.NewReader(body)) + buf := bytes.NewBuffer(make([]byte, 0)) + _, err := io.Copy(buf, brr) + if err != nil { + return nil, err + } + return buf.Bytes(), nil } return nil, EncodingNotSupport diff --git a/go.mod b/go.mod index 2fde2f0..cef5c16 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module github.com/lqqyt2423/go-mitmproxy go 1.15 require ( + github.com/andybalholm/brotli v1.0.1 github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e github.com/jordwest/mock-conn v0.0.0-20180617021051-4896c6bd1641 github.com/sirupsen/logrus v1.7.0 diff --git a/go.sum b/go.sum index 639882c..2d06e82 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,5 @@ +github.com/andybalholm/brotli v1.0.1 h1:KqhlKozYbRtJvsPrrEeXcO+N2l6NYT5A2QAFmSULpEc= +github.com/andybalholm/brotli v1.0.1/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e h1:1r7pUrabqp18hOBcwBwiTsbnFeTZHV9eER/QT5JVZxY=