Skip to content
This repository was archived by the owner on Jan 13, 2021. It is now read-only.

Stop being clever with bytes in CLI tool. #156

Merged
merged 1 commit into from
Aug 6, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ dev
a stream.
- Prevent hyper from emitting lots of RST_STREAM frames.
- Hyper CLI tool now correctly uses TLS for any ``https``-schemed URL.
- Hyper CLI tool no longer attempts to decode bytes, instead writing them
straight to the terminal.

*Software Updates*

Expand Down
6 changes: 2 additions & 4 deletions hyper/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,17 +223,15 @@ def request(args):
response = conn.get_response()
log.debug('Response Headers:\n%s', pformat(response.headers))
ctype, charset = get_content_type_and_charset(response)
data = response.read().decode(charset)
if 'json' in ctype:
data = pformat(json.loads(data))
data = response.read()
return data


def main(argv=None):
args = parse_argument(argv)
log.debug('Commandline Argument: %s', args)
data = request(args)
write_to_stdout(data.encode(PREFERRED_ENCODING, errors='replace'))
write_to_stdout(data)


if __name__ == '__main__': # pragma: no cover
Expand Down