mirror of
https://github.com/httpie/cli.git
synced 2025-02-09 13:14:03 +02:00
parent
284a75fa2f
commit
cbc6d02127
@ -25,6 +25,10 @@ def from_request(request):
|
|||||||
# requests < 0.12.1
|
# requests < 0.12.1
|
||||||
body = request._enc_data
|
body = request._enc_data
|
||||||
|
|
||||||
|
if isinstance(body, dict):
|
||||||
|
# --form
|
||||||
|
body = request.__class__._encode_params(body)
|
||||||
|
|
||||||
return HTTPMessage(
|
return HTTPMessage(
|
||||||
line='{method} {path} HTTP/1.1'.format(
|
line='{method} {path} HTTP/1.1'.format(
|
||||||
method=request.method,
|
method=request.method,
|
||||||
|
@ -122,6 +122,11 @@ class TestHTTPie(BaseTest):
|
|||||||
r = http('--verbose', 'GET', 'http://httpbin.org/get', 'test-header:__test__')
|
r = http('--verbose', 'GET', 'http://httpbin.org/get', 'test-header:__test__')
|
||||||
self.assertEqual(r.count('__test__'), 2)
|
self.assertEqual(r.count('__test__'), 2)
|
||||||
|
|
||||||
|
def test_verbose_form(self):
|
||||||
|
# https://github.com/jkbr/httpie/issues/53
|
||||||
|
r = http('--verbose', '--form', 'POST', 'http://httpbin.org/post', 'foo=bar', 'baz=bar')
|
||||||
|
self.assertIn('foo=bar&baz=bar', r)
|
||||||
|
|
||||||
def test_json(self):
|
def test_json(self):
|
||||||
response = http('POST', 'http://httpbin.org/post', 'foo=bar')
|
response = http('POST', 'http://httpbin.org/post', 'foo=bar')
|
||||||
self.assertIn('"foo": "bar"', response)
|
self.assertIn('"foo": "bar"', response)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user