Make default HTTP headers case-insensitive

Cloase #644
This commit is contained in:
Jakub Roztocil 2018-02-22 12:52:57 +01:00
parent 05547224ce
commit 0f4dce98c7
3 changed files with 22 additions and 4 deletions

View File

@ -9,9 +9,11 @@ This project adheres to `Semantic Versioning <http://semver.org/>`_.
`1.0.0-dev`_ (unreleased)
-------------------------
* Added ``true``/``false`` as valid values for ``--verify``
(in addition to ``yes``/``no``) and the boolean value is case-insensitive.
* Fixed default headers being incorrectly case-sensitive.
* Removed Python 2.6 support.
* ``--verify`` now accepts ``true``/``false`` in addition to ``yes``/``no``
and the boolean value is case-insensitive.
`0.9.8`_ (2016-12-08)

View File

@ -3,6 +3,7 @@ import sys
import requests
from requests.adapters import HTTPAdapter
from requests.structures import CaseInsensitiveDict
from httpie import sessions
from httpie import __version__
@ -106,9 +107,9 @@ def finalize_headers(headers):
def get_default_headers(args):
default_headers = {
default_headers = CaseInsensitiveDict({
'User-Agent': DEFAULT_UA
}
})
auto_json = args.data and not args.form
if args.json or auto_json:

View File

@ -7,6 +7,21 @@ from utils import MockEnvironment, http, HTTP_OK
from fixtures import FILE_PATH
def test_default_headers_case_insensitive(httpbin):
"""
<https://github.com/jakubroztocil/httpie/issues/644>
"""
r = http(
'--debug',
'--print=H',
httpbin.url + '/post',
'CONTENT-TYPE:application/json-patch+json',
'a=b',
)
assert 'CONTENT-TYPE: application/json-patch+json' in r
assert 'Content-Type' not in r
class TestImplicitHTTPMethod:
def test_implicit_GET(self, httpbin):
r = http(httpbin.url + '/get')