1
0
mirror of https://github.com/httpie/cli.git synced 2025-08-10 22:42:05 +02:00

More liberal default JSON Accept header

Closes #470
This commit is contained in:
Jakub Roztocil
2016-07-02 14:18:36 +02:00
parent 41e822ca2f
commit 49a0fb6e0f
4 changed files with 20 additions and 17 deletions

View File

@@ -2,6 +2,7 @@
Tests for the provided defaults regarding HTTP method, and --json vs. --form.
"""
from httpie.client import JSON_ACCEPT
from utils import TestEnvironment, http, HTTP_OK
from fixtures import FILE_PATH
@@ -58,20 +59,20 @@ class TestAutoContentTypeAndAcceptHeaders:
def test_POST_with_data_auto_JSON_headers(self, httpbin):
r = http('POST', httpbin.url + '/post', 'a=b')
assert HTTP_OK in r
assert '"Accept": "application/json"' in r
assert '"Content-Type": "application/json' in r
assert r.json['headers']['Accept'] == JSON_ACCEPT
assert r.json['headers']['Content-Type'] == 'application/json'
def test_GET_with_data_auto_JSON_headers(self, httpbin):
# JSON headers should automatically be set also for GET with data.
r = http('POST', httpbin.url + '/post', 'a=b')
assert HTTP_OK in r
assert '"Accept": "application/json"' in r, r
assert '"Content-Type": "application/json' in r
assert r.json['headers']['Accept'] == JSON_ACCEPT
assert r.json['headers']['Content-Type'] == 'application/json'
def test_POST_explicit_JSON_auto_JSON_accept(self, httpbin):
r = http('--json', 'POST', httpbin.url + '/post')
assert HTTP_OK in r
assert r.json['headers']['Accept'] == 'application/json'
assert r.json['headers']['Accept'] == JSON_ACCEPT
# Make sure Content-Type gets set even with no data.
# https://github.com/jkbrzt/httpie/issues/137
assert 'application/json' in r.json['headers']['Content-Type']