spulec / uncurl

A library to convert curl requests to python-requests.
Apache License 2.0
607 stars 94 forks source link

feature(uncurl/api.py): Add recognizing the --user and -u #39

Closed Lizon2501 closed 3 years ago

Lizon2501 commented 3 years ago

We add a feature ,it can recognize curl (--user/-u) parameter example:

curl http://host   -u name:password
####
requests.get("http://host",
    headers={},
    cookies={},
    auth=('name', 'password')
)
####
curl 'https://pypi.python.org/pypi/uncurl' --data '{"evt":"newsletter.show","properties":{"newsletter_type":"userprofile"}}' -H 'Accept-Encoding: gzip,deflate,sdch' -H 'Cookie: foo=bar; baz=baz2'
####
requests.post("https://pypi.python.org/pypi/uncurl",
    data='{"evt":"newsletter.show","properties":{"newsletter_type":"userprofile"}}',
    headers={
        "Accept-Encoding": "gzip,deflate,sdch"
    },
    cookies={
        "baz": "baz2",
        "foo": "bar"
    },
    auth=()
)
spulec commented 3 years ago

Looks good. Can you add a test for the new behavior too?

Lizon2501 commented 3 years ago

Looks good. Can you add a test for the new behavior too?

I have updated the tests for new behavior. And I also fix a typo in test_colon_header()

-H ':authority:mobile.twitter.com'
-H 'authority:mobile.twitter.com'

than I run all python requests, all of them response 200.

spulec commented 3 years ago

Thanks!