mirror of
https://github.com/bettercap/bettercap
synced 2025-08-20 21:43:18 -07:00
add boolean for dumping HTTP bodies in hex format
This commit is contained in:
parent
3d6e28ea45
commit
5ab45693c5
1 changed files with 19 additions and 6 deletions
|
@ -89,12 +89,21 @@ func (mod *EventsStream) dumpGZIP(body []byte) string {
|
|||
buffer := bytes.NewBuffer(body)
|
||||
uncompressed := bytes.Buffer{}
|
||||
reader, err := gzip.NewReader(buffer)
|
||||
if mod.dumpFormatHex {
|
||||
if err != nil {
|
||||
return mod.dumpRaw(body)
|
||||
} else if _, err = uncompressed.ReadFrom(reader); err != nil {
|
||||
return mod.dumpRaw(body)
|
||||
}
|
||||
return mod.dumpRaw(uncompressed.Bytes())
|
||||
} else {
|
||||
if err != nil {
|
||||
return mod.dumpText(body)
|
||||
} else if _, err = uncompressed.ReadFrom(reader); err != nil {
|
||||
return mod.dumpText(body)
|
||||
}
|
||||
return mod.dumpText(uncompressed.Bytes())
|
||||
}
|
||||
}
|
||||
|
||||
func (mod *EventsStream) dumpJSON(body []byte) string {
|
||||
|
@ -149,7 +158,11 @@ func (mod *EventsStream) viewHttpRequest(e session.Event) {
|
|||
} else if req.IsType("application/json") {
|
||||
dump += mod.dumpJSON(req.Body)
|
||||
} else {
|
||||
if mod.dumpFormatHex {
|
||||
dump += mod.dumpRaw(req.Body)
|
||||
} else {
|
||||
dump += mod.dumpText(req.Body)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue