Change default JSON Accept to application/json, */*;q=0.5

See #488
This commit is contained in:
Jakub Roztocil 2020-04-13 22:06:02 +02:00
parent 83bd8059de
commit fc85988368

View File

@ -2,7 +2,7 @@
Tests for the provided defaults regarding HTTP method, and --json vs. --form.
"""
from httpie.client import EXPLICIT_JSON_ACCEPT, AUTO_JSON_ACCEPT
from httpie.client import JSON_ACCEPT
from utils import MockEnvironment, http, HTTP_OK
from fixtures import FILE_PATH
@ -75,20 +75,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 r.json['headers']['Accept'] == AUTO_JSON_ACCEPT
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 r.json['headers']['Accept'] == AUTO_JSON_ACCEPT
assert r.json['headers']['Accept'] == JSON_ACCEPT
assert r.json['headers']['Content-Type'] == 'application/json'
def test_POST_explicit_JSON_JSON_ACCEPT(self, httpbin):
r = http('--json', 'POST', httpbin.url + '/post')
assert HTTP_OK in r
assert r.json['headers']['Accept'] == EXPLICIT_JSON_ACCEPT
assert r.json['headers']['Accept'] == JSON_ACCEPT
# Make sure Content-Type gets set even with no data.
# https://github.com/jakubroztocil/httpie/issues/137
assert 'application/json' in r.json['headers']['Content-Type']