diff --git a/httpie/__main__.py b/httpie/__main__.py index e469e03e..713bda13 100644 --- a/httpie/__main__.py +++ b/httpie/__main__.py @@ -100,13 +100,15 @@ def main(args=None, body = prettify.body(body, response.headers['Content-Type']) # Output. + # TODO: preserve leading/trailing whitespaces in the body. + # Some of the Pygments styles add superfluous line breaks. if args.print_headers: - stdout.write(status_line) + stdout.write(status_line.strip()) stdout.write('\n') - stdout.write(headers.encode('utf-8')) + stdout.write(headers.strip().encode('utf-8')) stdout.write('\n\n') if args.print_body: - stdout.write(body.encode('utf-8')) + stdout.write(body.strip().encode('utf-8')) stdout.write('\n') diff --git a/httpie/pretty.py b/httpie/pretty.py index 3e4fea09..49870449 100644 --- a/httpie/pretty.py +++ b/httpie/pretty.py @@ -42,7 +42,7 @@ class PrettyHttp(object): self.formatter = FORMATTER(style=style) def headers(self, content): - return pygments.highlight(content, HTTPLexer(), self.formatter).strip() + return pygments.highlight(content, HTTPLexer(), self.formatter) def body(self, content, content_type): content_type = content_type.split(';')[0] @@ -59,6 +59,4 @@ class PrettyHttp(object): except ClassNotFound: return content content = pygments.highlight(content, lexer, self.formatter) - # TODO: Make sure the leading/trailing whitespaces remain. - # Some of the Pygments styles add superfluous line breaks. - return content.strip() + return content