dcb9 / curl2httpie Goto Github PK
View Code? Open in Web Editor NEWcovert command arguments between cURL and HTTPie
Home Page: https://curl2httpie.online
License: MIT License
covert command arguments between cURL and HTTPie
Home Page: https://curl2httpie.online
License: MIT License
HTTPie supports URL shortcuts for localhost
, but currently the curl2httpie converter doesn't take this into account it seems.
Additionally, curl-like shorthand for localhost is supported. This means that, for example :3000 would expand to http://localhost:3000 If the port is omitted, then port 80 is assumed.
http :/foo
GET /foo HTTP/1.1
Host: localhost
Currently, the conversion doesn't take into account the absence of a domain.
Input: http :/foo
Actual output: curl ':/foo'
Unfortunately, curl on my macOS says:
tvinke@localhost ~ $ curl ':/foo'
curl: (3) Bad URL, colon is first character
Taking above mentioned defaults into account, I think probably below tests should pass after implementing the correct support for URL shortcuts.
Input: http :/foo
Expected output: curl 'http://localhost/foo'
Input: http :3000/bar
Expected output: curl 'http://localhost:3000/bar'
Input: http :
Expected output: curl 'http://localhost'
Hi, and thanks for making this great tool.
I was wondering what license this project uses. Could this be clarified via a LICENSE.md
file?
Thank you for the tool! We link to it from xh's documentation.
https://curl2httpie.online/ doesn't load right now because the TLS certificate isn't valid for that domain. Can you fix it, or move the page to github.io?
Hi there!
This is a cool project - I'd be even cooler if you could do inverse conversion.
This would be useful when you prototype requests with httpie and need to run them on some system without httpie installed.
curl "https://httpbin.org/get?1=2&3=4"
is converted to
http GET https://httpbin.org/get?1=2&3=4
which will result to
^C
[1]+ Done
Expected
http GET "https://httpbin.org/get?1=2&3=4"
Single quoted could be a choice too
Thanks a lot for this tool. I had a working curl example that I just couldn't get working under httpie, and this tool did guide me to my mistake.
There are 2 things I noticed which can be improved, however. This was my input:
curl -kX POST -d 'username=admin&password=12345' https://example.com/api/tokens
This was the output:
http --form POST 'https://example.com/api/tokens' 'username=admin' 'password=12345'
First thing, the httpie convention is to not use the protocol in the URL, but by using the appropriate http
/https
command:
https --form POST 'example.com/api/tokens' 'username=admin' 'password=12345'
Second thing, there was a message at the bottom of the page:
skipped: option "insecure" is not supported
The httpie equivalent to curl's -k
is --verify=no
.
curl -H 'Host: foo.bar.com' -H 'Accept: */*' -H 'User-Agent: debug-MyAppName/ CFNetwork/893.14 Darwin/17.4.0' -H 'Accept-Language: en-us' --data "client_id=foobarfoobarfoobar&client_secret=bazquzbazquz&grant_type=password&password=SomePasswordHere&scope=user&username=first.last%2B1%40domain.com" --compressed 'https://stage.domain.com/api/oauth/token'
Nothing happens when I try to convert this query.
The conversion for this httpie command works: http -a username:password pie.dev/basic auth/username/password
But if we specify the user:password at the end the conversion fails: http pie.dev/basic auth/username/password -a username:password
The httpie command http :8080/xxx out_1[in_1]=value_1 out_2[in_2]=value_2 out_3=value_3
sends the following payload:
{
"out_1": {
"in_1": "value_1"
},
"out_2": {
"in_2": "value_2"
},
"out_3": "value_3"
}
But the online tool creates the following curl command:
curl --header 'Content-Type: application/json' --data '{"out_1[in_1]":"value_1","out_2[in_2]":"value_2","out_3":"value_3"}' localhost:8080/xxx
Which sends the payload {"asId[ipv4addr]":"1.1.1.1","qos":"QOS_E","ueId[msisdn]":"+34666777888"}
e.g:
curl 'https://xxx/v1/tokens' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:69.0) Gecko/20100101 Firefox/69.0' -H 'Accept: application/vnd.api+json' -H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'Content-Type: application/vnd.api+json' -H 'Origin: https://xxx' -H 'Connection: keep-alive' -H 'Referer: https://xxx' -H 'Pragma: no-cache' -H 'Cache-Control: no-cache' --data '{"auth":{"email":"xxx","password":"xxx"}}'
should be HTTP POST ... now is GET
curl --request "POST" --header "Content-Type: application/json" --data "{\"foo\":\"bar\"}" 'https://httpbin.org/anything'
won't translate into an http
command.
Is there a command-line option?
Proxy at work blocking the webpage.
converting
http \
POST https://httpbin.org/anything \
foo=bar
gives
curl '\'
but it should be the same as
http
POST https://httpbin.org/anything
foo=bar
which gives
curl --request "POST" --header "Content-Type: application/json" --data "{\"foo\":\"bar\"}" 'https://httpbin.org/anything'
Can't access the online site:
http --verbose curl2httpie.online
GET / HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Host: curl2httpie.online
User-Agent: HTTPie/2.4.0
http: error: ConnectionError: HTTPConnectionPool(host='curl2httpie.online', port=80): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x10927cdc0>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known')) while doing a GET request to URL: http://curl2httpie.online/
Httpie commands that are not secure (http) work fine, but those with SSL (https) not.
Example: https pie.dev
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.