Changed the default JSON Content-Type to application/json.

This commit is contained in:
Jakub Roztocil 2015-02-14 17:44:47 +01:00
parent 748794257c
commit 6e7e2f2eea
3 changed files with 10 additions and 7 deletions

View File

@ -362,7 +362,7 @@ object by default. HTTPie also automatically sets the following headers,
both of which can be overwritten:
================ =======================================
``Content-Type`` ``application/json; charset=utf-8``
``Content-Type`` ``application/json``
``Accept`` ``application/json``
================ =======================================
@ -382,7 +382,7 @@ Simple example:
PUT / HTTP/1.1
Accept: application/json
Accept-Encoding: identity, deflate, compress, gzip
Content-Type: application/json; charset=utf-8
Content-Type: application/json
Host: example.org
{
@ -408,7 +408,7 @@ fields using ``=@`` and ``:=@``:
PUT /person/1 HTTP/1.1
Accept: application/json
Content-Type: application/json; charset=utf-8
Content-Type: application/json
Host: api.example.com
{
@ -727,7 +727,7 @@ documentation examples:
PUT /put HTTP/1.1
Accept: application/json
Accept-Encoding: identity, deflate, compress, gzip
Content-Type: application/json; charset=utf-8
Content-Type: application/json
Host: httpbin.org
User-Agent: HTTPie/0.2.7dev
@ -1314,6 +1314,9 @@ Changelog
*You can click a version name to see a diff with the previous one.*
* `1.0.0-dev`_
* Changed the default JSON ``Content-Type``
from ``application/json; charset=utf-8`` to ``application/json``
as UTF-8 is the default encoding for JSON.
* `0.9.1`_ (2015-02-07)
* Added support for Requests transport adapter plugins
to enable plugin-provided features such as

View File

@ -11,7 +11,7 @@ from httpie.plugins import plugin_manager
FORM = 'application/x-www-form-urlencoded; charset=utf-8'
JSON = 'application/json; charset=utf-8'
JSON = 'application/json'
DEFAULT_UA = 'HTTPie/%s' % __version__

View File

@ -59,14 +59,14 @@ class TestAutoContentTypeAndAcceptHeaders:
r = http('POST', httpbin.url + '/post', 'a=b')
assert HTTP_OK in r
assert '"Accept": "application/json"' in r
assert '"Content-Type": "application/json; charset=utf-8' in r
assert '"Content-Type": "application/json' in r
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; charset=utf-8' in r
assert '"Content-Type": "application/json' in r
def test_POST_explicit_JSON_auto_JSON_accept(self, httpbin):
r = http('--json', 'POST', httpbin.url + '/post')