Corrected line breaks in the output.

This commit is contained in:
Jakub Roztočil 2012-03-04 13:03:21 +01:00
parent bd9209f77a
commit ebb271334b
2 changed files with 7 additions and 7 deletions

View File

@ -100,13 +100,15 @@ def main(args=None,
body = prettify.body(body, response.headers['Content-Type']) body = prettify.body(body, response.headers['Content-Type'])
# Output. # Output.
# TODO: preserve leading/trailing whitespaces in the body.
# Some of the Pygments styles add superfluous line breaks.
if args.print_headers: if args.print_headers:
stdout.write(status_line) stdout.write(status_line.strip())
stdout.write('\n') stdout.write('\n')
stdout.write(headers.encode('utf-8')) stdout.write(headers.strip().encode('utf-8'))
stdout.write('\n\n') stdout.write('\n\n')
if args.print_body: if args.print_body:
stdout.write(body.encode('utf-8')) stdout.write(body.strip().encode('utf-8'))
stdout.write('\n') stdout.write('\n')

View File

@ -42,7 +42,7 @@ class PrettyHttp(object):
self.formatter = FORMATTER(style=style) self.formatter = FORMATTER(style=style)
def headers(self, content): 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): def body(self, content, content_type):
content_type = content_type.split(';')[0] content_type = content_type.split(';')[0]
@ -59,6 +59,4 @@ class PrettyHttp(object):
except ClassNotFound: except ClassNotFound:
return content return content
content = pygments.highlight(content, lexer, self.formatter) content = pygments.highlight(content, lexer, self.formatter)
# TODO: Make sure the leading/trailing whitespaces remain. return content
# Some of the Pygments styles add superfluous line breaks.
return content.strip()