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

Fix for curl command #214

Merged
merged 1 commit into from
Jan 28, 2020
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ internal object FormatUtils {

fun getShareCurlCommand(transaction: HttpTransaction): String {
var compressed = false
var curlCmd = "curl -X $transaction.method"
var curlCmd = "curl -X ${transaction.method}"
val headers = transaction.getParsedRequestHeaders()

headers?.forEach { header ->
Expand All @@ -154,13 +154,13 @@ internal object FormatUtils {
) {
compressed = true
}
curlCmd += " -H \"$header.name: $header.value\""
curlCmd += " -H \"${header.name}: ${header.value}\""
}

val requestBody = transaction.requestBody
if (!requestBody.isNullOrEmpty()) {
// try to keep to a single line and use a subshell to preserve any line breaks
curlCmd += " --data $'$requestBody.replace(\"\\n\", \"\\\\n\")'"
curlCmd += " --data $'${requestBody.replace("\n", "\\n")}'"
}
curlCmd += (if (compressed) " --compressed " else " ") + transaction.url
return curlCmd
Expand Down