1
0
mirror of https://github.com/httpie/cli.git synced 2024-11-28 08:38:44 +02:00

Improved request formatting.

This commit is contained in:
Jakub Roztocil 2012-03-14 19:30:58 +01:00
parent ccbea8c96e
commit e2e749b2a6
2 changed files with 9 additions and 4 deletions

View File

@ -39,9 +39,9 @@ def format_http_message(message, prettifier=None,
else:
bits.append(message.line)
bits.append(message.headers)
if with_body:
if with_body and message.body:
bits.append('\n')
if with_body:
if with_body and message.body:
if prettifier and message.content_type:
bits.append(prettifier.body(message.body, message.content_type))
else:

View File

@ -26,9 +26,14 @@ class HTTPLexer(RegexLexer):
tokens = {
'root': [
(r'\s+', token.Text),
# Request-Line
(r'([A-Z]+\s+)(/.*?)(\s+HTTP/[\d.]+)', bygroups(
token.Keyword, token.String, token.Keyword)),
# Status-Line
(r'(HTTP/[\d.]+\s+)(\d+)(\s+.+)', bygroups(
token.Operator, token.Number, token.String)),
(r'(.*?:)(.+)', bygroups(token.Name, token.String))
token.Keyword, token.Number, token.String)),
# Header
(r'(.*?:)(.+)', bygroups(token.Name, token.Keyword))
]}