Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Changed the default JSON Content-Type to application/json.
  • Loading branch information
jkbrzt committed Feb 14, 2015
1 parent 7487942 commit 6e7e2f2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
11 changes: 7 additions & 4 deletions README.rst
Expand Up @@ -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``
================ =======================================
Expand All @@ -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
{
Expand All @@ -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
{
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion httpie/client.py
Expand Up @@ -11,7 +11,7 @@


FORM = 'application/x-www-form-urlencoded; charset=utf-8'
JSON = 'application/json; charset=utf-8'
JSON = 'application/json'
DEFAULT_UA = 'HTTPie/%s' % __version__


Expand Down
4 changes: 2 additions & 2 deletions tests/test_defaults.py
Expand Up @@ -59,14 +59,14 @@ 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; 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')
Expand Down

0 comments on commit 6e7e2f2

Please sign in to comment.