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

Curl Share Option #14

Closed
droidluv opened this issue Sep 5, 2019 · 0 comments
Closed

Curl Share Option #14

droidluv opened this issue Sep 5, 2019 · 0 comments

Comments

@droidluv
Copy link
Contributor

droidluv commented Sep 5, 2019

This is a feature request, since this project is inspired from Chuck the one feature which I sorely miss is the capability to share a curl, since constructing a curl is fairly easy in Chuck the curl generation code should look like

    var compressed = false
    var curlCmd = "curl"
    curlCmd += " -X " + v(transaction?.method)
    val headers = transaction?.requestHeaders ?: emptyList()
    var i = 0
    val count = headers.size
    while (i < count) {
        val name = headers[i].name
        val value = headers[i].value
        if ("Accept-Encoding".equals(name, ignoreCase = true) && "gzip".equals(value, ignoreCase = true)) {
            compressed = true
        }
        curlCmd += " -H \'$name: $value\'"
        i++
    }
    val requestBody = v(transaction?.requestBody)
    if (requestBody.isNotEmpty()) {
        // try to keep to a single line and use a subshell to preserve any line breaks
        curlCmd += " --data $'" + requestBody.replace("\n", "\\n") + "'"
    }
    curlCmd += (if (compressed) " --compressed " else " ") + "\'${v(transaction?.url)}\'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants