Code Monkey home page Code Monkey logo

curl2httpie's People

Contributors

dcb9 avatar maelvls avatar yetingsky avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

curl2httpie's Issues

Support URL shortcuts for localhost

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

Actual: Bad URL, colon is first character

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

image

Expected

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'

Missing License information

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?

Query parameters are not quoted

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

protocol conversion and -k

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.

This request won't convert

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.

[bug] Nested json is not parsed correctly

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"}

curl data should be convert to http post rather then get

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

Escaped linebreaks

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'

Site is Offline

Can't access the online site:

image

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/

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.