curlconverter / curlconverter

Transpile curl commands into Python, JavaScript and 27 other languages
https://curlconverter.com
MIT License
7.21k stars 876 forks source link

raw HTTP format #418

Closed zuisong closed 1 year ago

zuisong commented 1 year ago
curl 'http://fiddle.jshell.net/echo/html/' \
    -H 'Origin: http://fiddle.jshell.net' \
    -H 'Accept-Encoding: gzip, deflate' \
    -H 'Accept-Language: en-US,en;q=0.8' \
    -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36' \
    -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \
    -H 'Accept: */*' \
    -H 'Referer: http://fiddle.jshell.net/_display/' \
    -H 'X-Requested-With: XMLHttpRequest' \
    -H 'Connection: keep-alive' \
    --data 'msg1=wow&msg2=such&msg3=data' --compressed

convert to

POST /echo/html/ HTTP/1.1
Host: fiddle.jshell.net
Origin: http://fiddle.jshell.net
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.8
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Accept: */*
Referer: http://fiddle.jshell.net/_display/
X-Requested-With: XMLHttpRequest
Connection: keep-alive

msg1=wow&msg2=such&msg3=data
zuisong commented 1 year ago

I would like to make a Pull request for this feature😄

verhovsky commented 1 year ago

curl lets you see everything it sends already with

curl -vvv www.example.com
# or
curl --trace-ascii - www.example.com

I agree that it would be pretty fun if we had this feature, but I'm curious what you want to use this for. Is there a specific use-case you have in mind?

zuisong commented 1 year ago

vscode have many http-client-tool to send http requests with dynamic variable , but almost all of them use raw http format . It will be very helpful to me if curlconverter plugin can auto convert curl to raw http format.

https://marketplace.visualstudio.com/items?itemName=humao.rest-client https://marketplace.visualstudio.com/items?itemName=anweber.vscode-httpyac

verhovsky commented 1 year ago

That's unfortunate, because the VS Code extension is running an old version because we made curlconverter an ESM module, and VS Code extensions can't use ESM modules https://github.com/curlconverter/curlconverter-vscode/issues/1

zuisong commented 1 year ago

If I can use curlconverter to generate code from web, it will be ok to be 😄