Skip to content

Commit

Permalink
Compatibility with requests v1.0.4 (requests URL params).
Browse files Browse the repository at this point in the history
  • Loading branch information
jkbrzt committed Jan 3, 2013
1 parent 80e317f commit 0ae9d7a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 17 deletions.
19 changes: 3 additions & 16 deletions httpie/models.py
@@ -1,8 +1,8 @@
import os
import sys
from .compat import urlsplit, is_windows, bytes, str

from .config import DEFAULT_CONFIG_DIR, Config
from .compat import urlsplit, is_windows, bytes, str


class Environment(object):
Expand Down Expand Up @@ -144,29 +144,16 @@ def iter_lines(self, chunk_size):
def headers(self):
url = urlsplit(self._orig.url)

# Querystring
qs = ''
if url.query or self._orig.params:
qs = '?'
if url.query:
qs += url.query
# Requests doesn't make params part of ``request.url``.
if self._orig.params:
if url.query:
qs += '&'
qs += type(self._orig)._encode_params(self._orig.params)

# Request-Line
request_line = '{method} {path}{query} HTTP/1.1'.format(
method=self._orig.method,
path=url.path or '/',
query=qs
query='?' + url.query if url.query else ''
)

headers = dict(self._orig.headers)

if 'Host' not in headers:
headers['Host'] = urlsplit(self._orig.url).netloc
headers['Host'] = url.netloc

headers = ['%s: %s' % (name, value)
for name, value in headers.items()]
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -12,7 +12,7 @@


requirements = [
'requests>=1.0.3',
'requests>=1.0.4',
'Pygments>=1.5'
]
if sys.version_info[:2] in ((2, 6), (3, 1)):
Expand Down

0 comments on commit 0ae9d7a

Please sign in to comment.