mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-07-23 20:49:26 +00:00
Fix the issues in HTTP POST data
This commit is contained in:
parent
60a6be677f
commit
4cd5fc25fd
@ -3,7 +3,7 @@ module github.com/up9inc/mizu/tap/extensions/http
|
|||||||
go 1.16
|
go 1.16
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/google/martian v2.1.0+incompatible // indirect
|
github.com/google/martian v2.1.0+incompatible
|
||||||
github.com/romana/rlog v0.0.0-20171115192701-f018bc92e7d7
|
github.com/romana/rlog v0.0.0-20171115192701-f018bc92e7d7
|
||||||
github.com/up9inc/mizu/tap/api v0.0.0
|
github.com/up9inc/mizu/tap/api v0.0.0
|
||||||
golang.org/x/net v0.0.0-20210224082022-3d97a244fca7
|
golang.org/x/net v0.0.0-20210224082022-3d97a244fca7
|
||||||
|
@ -4,15 +4,9 @@ github.com/romana/rlog v0.0.0-20171115192701-f018bc92e7d7 h1:jkvpcEatpwuMF5O5LVx
|
|||||||
github.com/romana/rlog v0.0.0-20171115192701-f018bc92e7d7/go.mod h1:KTrHyWpO1sevuXPZwyeZc72ddWRFqNSKDFl7uVWKpg0=
|
github.com/romana/rlog v0.0.0-20171115192701-f018bc92e7d7/go.mod h1:KTrHyWpO1sevuXPZwyeZc72ddWRFqNSKDFl7uVWKpg0=
|
||||||
golang.org/x/net v0.0.0-20210224082022-3d97a244fca7 h1:OgUuv8lsRpBibGNbSizVwKWlysjaNzmC9gYMhPVfqFM=
|
golang.org/x/net v0.0.0-20210224082022-3d97a244fca7 h1:OgUuv8lsRpBibGNbSizVwKWlysjaNzmC9gYMhPVfqFM=
|
||||||
golang.org/x/net v0.0.0-20210224082022-3d97a244fca7/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
golang.org/x/net v0.0.0-20210224082022-3d97a244fca7/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||||
golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d h1:LO7XpTYMwTqxjLcGWPijK3vRXg1aWdlNOVOHRq45d7c=
|
|
||||||
golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
|
||||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.3.5 h1:i6eZZ+zk0SOf0xgBpEpPD18qWcJda6q1sxt3S0kzyUQ=
|
golang.org/x/text v0.3.5 h1:i6eZZ+zk0SOf0xgBpEpPD18qWcJda6q1sxt3S0kzyUQ=
|
||||||
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
|
||||||
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
|
|
||||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
|
@ -235,20 +235,43 @@ func representRequest(request map[string]interface{}) []interface{} {
|
|||||||
|
|
||||||
postData, _ := request["postData"].(map[string]interface{})
|
postData, _ := request["postData"].(map[string]interface{})
|
||||||
mimeType, _ := postData["mimeType"]
|
mimeType, _ := postData["mimeType"]
|
||||||
if mimeType == nil {
|
if mimeType == nil || len(mimeType.(string)) == 0 {
|
||||||
mimeType = "N/A"
|
mimeType = "text/html"
|
||||||
}
|
}
|
||||||
text, _ := postData["text"]
|
text, _ := postData["text"]
|
||||||
if text != nil {
|
if text != nil {
|
||||||
repRequest = append(repRequest, map[string]string{
|
repRequest = append(repRequest, map[string]string{
|
||||||
"type": "body",
|
"type": "body",
|
||||||
"title": "POST Data",
|
"title": "POST Data (text/plain)",
|
||||||
"encoding": "base64", // FIXME: Does `request` have it?
|
"encoding": "",
|
||||||
"mime_type": mimeType.(string),
|
"mime_type": mimeType.(string),
|
||||||
"data": text.(string),
|
"data": text.(string),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
params, _ := json.Marshal(postData["params"].([]interface{}))
|
||||||
|
if len(params) > 0 {
|
||||||
|
if mimeType == "multipart/form-data" {
|
||||||
|
multipart, _ := json.Marshal([]map[string]string{
|
||||||
|
{
|
||||||
|
"name": "Files",
|
||||||
|
"value": string(params),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
repRequest = append(repRequest, map[string]string{
|
||||||
|
"type": "table",
|
||||||
|
"title": "POST Data (multipart/form-data)",
|
||||||
|
"data": string(multipart),
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
repRequest = append(repRequest, map[string]string{
|
||||||
|
"type": "table",
|
||||||
|
"title": "POST Data (application/x-www-form-urlencoded)",
|
||||||
|
"data": string(params),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return repRequest
|
return repRequest
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -291,6 +314,9 @@ func representResponse(response map[string]interface{}) []interface{} {
|
|||||||
|
|
||||||
content, _ := response["content"].(map[string]interface{})
|
content, _ := response["content"].(map[string]interface{})
|
||||||
mimeType, _ := content["mimeType"]
|
mimeType, _ := content["mimeType"]
|
||||||
|
if mimeType == nil || len(mimeType.(string)) == 0 {
|
||||||
|
mimeType = "text/html"
|
||||||
|
}
|
||||||
encoding, _ := content["encoding"]
|
encoding, _ := content["encoding"]
|
||||||
text, _ := content["text"]
|
text, _ := content["text"]
|
||||||
if text != nil {
|
if text != nil {
|
||||||
|
@ -28,7 +28,7 @@ type HTTPWrapper struct {
|
|||||||
func (h HTTPPayload) MarshalJSON() ([]byte, error) {
|
func (h HTTPPayload) MarshalJSON() ([]byte, error) {
|
||||||
switch h.Type {
|
switch h.Type {
|
||||||
case "http_request":
|
case "http_request":
|
||||||
harRequest, err := har.NewRequest(h.Data.(*http.Request), false)
|
harRequest, err := har.NewRequest(h.Data.(*http.Request), true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
rlog.Debugf("convert-request-to-har", "Failed converting request to HAR %s (%v,%+v)", err, err, err)
|
rlog.Debugf("convert-request-to-har", "Failed converting request to HAR %s (%v,%+v)", err, err, err)
|
||||||
return nil, errors.New("Failed converting request to HAR")
|
return nil, errors.New("Failed converting request to HAR")
|
||||||
|
Loading…
Reference in New Issue
Block a user