optimize web addon content-length showing

addon-dailer
liqiang 4 years ago
parent f59e7bfc25
commit fb9bb22d97

@ -9,8 +9,14 @@ export const isTextResponse = response => {
export const getSize = response => { export const getSize = response => {
if (!response) return '0' if (!response) return '0'
if (!response.header) return '0' if (!response.header) return '0'
if (!response.header['Content-Length']) return '0'
const len = parseInt(response.header['Content-Length'][0]) let len
if (response.header['Content-Length']) {
len = parseInt(response.header['Content-Length'][0])
} else if (response && response.body) {
len = response.body.byteLength
}
if (!len) return '0'
if (isNaN(len)) return '0' if (isNaN(len)) return '0'
if (len <= 0) return '0' if (len <= 0) return '0'

@ -81,7 +81,8 @@ func newMessageResponse(f *flow.Flow) *message {
} }
func newMessageResponseBody(f *flow.Flow) *message { func newMessageResponseBody(f *flow.Flow) *message {
return newMessage(messageTypeResponseBody, f.Id, f.Response.Body) body, _ := f.Response.DecodedBody()
return newMessage(messageTypeResponseBody, f.Id, body)
} }
func (m *message) bytes() []byte { func (m *message) bytes() []byte {

@ -54,7 +54,6 @@ func main() {
p.AddAddon(dumper) p.AddAddon(dumper)
} }
p.AddAddon(&addon.Decoder{})
p.AddAddon(web.NewWebAddon(config.webAddr)) p.AddAddon(web.NewWebAddon(config.webAddr))
log.Fatal(p.Start()) log.Fatal(p.Start())

Loading…
Cancel
Save