aboutsummaryrefslogtreecommitdiff
path: root/parsers
diff options
context:
space:
mode:
Diffstat (limited to 'parsers')
-rw-r--r--parsers/http_request_parser.go12
1 files changed, 4 insertions, 8 deletions
diff --git a/parsers/http_request_parser.go b/parsers/http_request_parser.go
index bc98f8f..56093c9 100644
--- a/parsers/http_request_parser.go
+++ b/parsers/http_request_parser.go
@@ -82,7 +82,7 @@ func (p HttpRequestParser) TryParse(content []byte) Metadata {
Trailer: JoinArrayMap(request.Trailer),
Reproducers: HttpRequestMetadataReproducers{
CurlCommand: curlCommand(content),
- RequestsCode: requestsCode(request),
+ RequestsCode: requestsCode(request, body),
FetchRequest: fetchRequest(request, body),
},
}
@@ -99,19 +99,15 @@ func curlCommand(content []byte) string {
}
}
-func requestsCode(request *http.Request) string {
+func requestsCode(request *http.Request, body string) string {
var b strings.Builder
- var params string
- if request.Form != nil {
- params = toJson(JoinArrayMap(request.PostForm))
- }
headers := toJson(JoinArrayMap(request.Header))
cookies := toJson(CookiesMap(request.Cookies()))
b.WriteString("import requests\n\nresponse = requests." + strings.ToLower(request.Method) + "(")
b.WriteString("\"" + request.URL.String() + "\"")
- if params != "" {
- b.WriteString(", data = " + params)
+ if body != "" {
+ b.WriteString(", data = \"" + strings.Replace(body, "\"", "\\\"", -1) + "\"")
}
if headers != "" {
b.WriteString(", headers = " + headers)