Fixed --verbose --form.

Closes #53
This commit is contained in:
Jakub Roztocil 2012-06-15 16:47:55 +02:00
parent 284a75fa2f
commit cbc6d02127
2 changed files with 9 additions and 0 deletions

View File

@ -25,6 +25,10 @@ def from_request(request):
# requests < 0.12.1
body = request._enc_data
if isinstance(body, dict):
# --form
body = request.__class__._encode_params(body)
return HTTPMessage(
line='{method} {path} HTTP/1.1'.format(
method=request.method,

View File

@ -122,6 +122,11 @@ class TestHTTPie(BaseTest):
r = http('--verbose', 'GET', 'http://httpbin.org/get', 'test-header:__test__')
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):
response = http('POST', 'http://httpbin.org/post', 'foo=bar')
self.assertIn('"foo": "bar"', response)