Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add formdata support #73

Merged
merged 1 commit into from
Dec 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions themes/helper_curl_snippet.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func curlSnippet(request postman.Request) string {
if payloadReady.MatchString(request.Method) {
if request.PayloadType == "urlencoded" {
curlSnippet += ` -H "Content-Type: application/x-www-form-urlencoded"`
} else if request.PayloadType == "params" {
} else if request.PayloadType == "params" || request.PayloadType == "formdata" {
curlSnippet += ` -H "Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW"`
}
}
Expand All @@ -35,7 +35,7 @@ func curlSnippet(request postman.Request) string {
dataList = append(dataList, fmt.Sprintf("%v=%v", data.Key, data.Value))
}
curlSnippet += fmt.Sprintf(` -d "%v"`, strings.Join(dataList, "&"))
} else if request.PayloadType == "params" {
} else if request.PayloadType == "params" || request.PayloadType == "formdata" {
for _, data := range request.PayloadParams {
curlSnippet += fmt.Sprintf(` -F "%v=%v"`, data.Key, data.Value)
}
Expand Down
2 changes: 1 addition & 1 deletion themes/helper_http_snippet.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Content-Type: application/x-www-form-urlencoded
%v`, strings.Join(dataList, "&"))
}

if request.PayloadType == "params" {
if request.PayloadType == "params" || request.PayloadType == "formdata" {
boundary := "----WebKitFormBoundary7MA4YWxkTrZu0gW"
httpSnippet += fmt.Sprintf(`
Content-Type: multipart/form-data; boundary=%v
Expand Down