Skip to content

Commit

Permalink
Merge branch 'master' of github.com:jkbr/httpie
Browse files Browse the repository at this point in the history
  • Loading branch information
jkbrzt committed Jul 16, 2012
2 parents 489bd64 + 2036337 commit 12f2fb4
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion httpie/pretty.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import re
import json

import pygments
Expand All @@ -18,6 +19,8 @@
if '256color' in os.environ.get('TERM', '')
else TerminalFormatter)

application_content_type_re = re.compile(r'application/(.+\+)?(json|xml)$')


class PrettyHttp(object):

Expand All @@ -33,12 +36,18 @@ def headers(self, content):

def body(self, content, content_type):
content_type = content_type.split(';')[0]
application_match = re.match(application_content_type_re, content_type)
if application_match:
# Strip vendor and extensions from Content-Type
vendor, extension = application_match.groups()
content_type = content_type.replace(vendor, u"")

try:
lexer = get_lexer_for_mimetype(content_type)
except ClassNotFound:
return content

if content_type == 'application/json':
if content_type == "application/json":
try:
# Indent and sort the JSON data.
content = json.dumps(json.loads(content),
Expand Down

0 comments on commit 12f2fb4

Please sign in to comment.