mirror of
https://github.com/bettercap/bettercap
synced 2025-08-14 02:36:57 -07:00
misc: small fix or general refactoring i did not bother commenting
This commit is contained in:
parent
b98db78926
commit
9469c37ef0
2 changed files with 16 additions and 8 deletions
|
@ -149,15 +149,15 @@ func (s *EventsStream) viewHttpRequest(e session.Event) {
|
|||
}
|
||||
|
||||
if req.Body != nil {
|
||||
if strings.Contains(req.ContentType, "application/x-www-form-urlencoded") {
|
||||
if req.IsType("application/x-www-form-urlencoded") {
|
||||
dump += s.dumpForm(req.Body)
|
||||
} else if strings.Contains(req.ContentType, "text/plain") {
|
||||
} else if req.IsType("text/plain") {
|
||||
dump += s.dumpText(req.Body)
|
||||
} else if strings.Contains(req.ContentType, "text/xml") {
|
||||
} else if req.IsType("text/xml") {
|
||||
dump += s.dumpXML(req.Body)
|
||||
} else if strings.Contains(req.ContentType, "gzip") {
|
||||
} else if req.IsType("gzip") {
|
||||
dump += s.dumpGZIP(req.Body)
|
||||
} else if strings.Contains(req.ContentType, "application/json") {
|
||||
} else if req.IsType("application/json") {
|
||||
dump += s.dumpJSON(req.Body)
|
||||
} else {
|
||||
dump += s.dumpRaw(req.Body)
|
||||
|
@ -187,11 +187,11 @@ func (s *EventsStream) viewHttpResponse(e session.Event) {
|
|||
|
||||
if res.Body != nil {
|
||||
// TODO: add more interesting response types
|
||||
if strings.Contains(res.ContentType, "text/plain") {
|
||||
if res.IsType("text/plain") {
|
||||
dump += s.dumpText(res.Body)
|
||||
} else if strings.Contains(res.ContentType, "application/json") {
|
||||
} else if res.IsType("application/json") {
|
||||
dump += s.dumpJSON(res.Body)
|
||||
} else if strings.Contains(res.ContentType, "text/xml") {
|
||||
} else if res.IsType("text/xml") {
|
||||
dump += s.dumpXML(res.Body)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,10 @@ type HTTPRequest struct {
|
|||
Body []byte `json:"body"`
|
||||
}
|
||||
|
||||
func (r HTTPRequest) IsType(ctype string) bool {
|
||||
return strings.Contains(r.ContentType, ctype)
|
||||
}
|
||||
|
||||
type HTTPResponse struct {
|
||||
Protocol string `json:"protocol"`
|
||||
Status string `json:"status"`
|
||||
|
@ -37,6 +41,10 @@ type HTTPResponse struct {
|
|||
TransferEncoding []string `json:"transfer_encoding"`
|
||||
}
|
||||
|
||||
func (r HTTPResponse) IsType(ctype string) bool {
|
||||
return strings.Contains(r.ContentType, ctype)
|
||||
}
|
||||
|
||||
func toSerializableRequest(req *http.Request) HTTPRequest {
|
||||
body := []byte(nil)
|
||||
ctype := "?"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue