Compare commits

...

5 Commits
0.2.3 ... 0.2.4

Author SHA1 Message Date
deeb7cbbac 0.2.4 (bad upload of 0.2.3 to pypi). 2012-07-17 00:44:25 +02:00
12f2fb4a92 Merge branch 'master' of github.com:jkbr/httpie 2012-07-17 00:38:41 +02:00
489bd64295 0.2.4dev 2012-07-17 00:37:53 +02:00
2036337a53 Merge pull request #69 from jokull/master
Prettify vendor+json and vendor+xml Content-Type responses
2012-07-16 15:27:50 -07:00
36de166b28 Simplify vendor extension content-types since they are most likely lexable 2012-07-14 14:27:11 +00:00
3 changed files with 12 additions and 3 deletions

View File

@ -225,7 +225,7 @@ Before a pull requests is submitted, it's a good idea to run the existing suite
Changelog
---------
* `0.2.3 <https://github.com/jkbr/httpie/compare/0.2.2...0.2.3>`_ (2012-06-24)
* `0.2.4 <https://github.com/jkbr/httpie/compare/0.2.2...0.2.4>`_ (2012-06-24)
* Unicode characters in prettified JSON now don't get escaped to improve readability.
* --auth now prompts for a password if only a username provided.
* Added support for request payloads from a file path with automatic ``Content-Type`` (``http URL @/path``).

View File

@ -3,5 +3,5 @@ HTTPie - cURL for humans.
"""
__author__ = 'Jakub Roztocil'
__version__ = '0.2.3'
__version__ = '0.2.4'
__licence__ = 'BSD'

View File

@ -1,4 +1,5 @@
import os
import re
import json
import pygments
@ -18,6 +19,8 @@ FORMATTER = (Terminal256Formatter
if '256color' in os.environ.get('TERM', '')
else TerminalFormatter)
application_content_type_re = re.compile(r'application/(.+\+)?(json|xml)$')
class PrettyHttp(object):
@ -33,12 +36,18 @@ class PrettyHttp(object):
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),