content-encoding br support

addon-dailer
lqqyt2423 4 years ago
parent 9ded568d41
commit 44d7815e68

@ -6,6 +6,8 @@ import (
"errors" "errors"
"io" "io"
"strings" "strings"
"github.com/andybalholm/brotli"
) )
// handle http header: content-encoding // handle http header: content-encoding
@ -89,6 +91,14 @@ func Decode(enc string, body []byte) ([]byte, error) {
return nil, err return nil, err
} }
return buf.Bytes(), nil 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 return nil, EncodingNotSupport

@ -3,6 +3,7 @@ module github.com/lqqyt2423/go-mitmproxy
go 1.15 go 1.15
require ( require (
github.com/andybalholm/brotli v1.0.1
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e
github.com/jordwest/mock-conn v0.0.0-20180617021051-4896c6bd1641 github.com/jordwest/mock-conn v0.0.0-20180617021051-4896c6bd1641
github.com/sirupsen/logrus v1.7.0 github.com/sirupsen/logrus v1.7.0

@ -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 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 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= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e h1:1r7pUrabqp18hOBcwBwiTsbnFeTZHV9eER/QT5JVZxY=

Loading…
Cancel
Save