Skip to content

Commit

Permalink
Merge 136fbcf into 64f6f69
Browse files Browse the repository at this point in the history
  • Loading branch information
yashsriv committed Oct 14, 2016
2 parents 64f6f69 + 136fbcf commit 6e5f645
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
11 changes: 11 additions & 0 deletions httpie/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,17 @@ def _split_lines(self, text, width):
"""
)
content_type.add_argument(
'--xssi', '-x',
dest='xssi_prefix',
metavar='PREFIX',
default='',
help="""
(default) Assumes incoming JSON has no XSSI Prefix
Allows Specifying a particular XSSI Prefix for the incoming JSON.
"""
)
content_type.add_argument(
'--form', '-f',
action='store_true',
Expand Down
4 changes: 4 additions & 0 deletions httpie/output/formatters/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ def format_body(self, body, mime):
]
if (self.kwargs['explicit_json'] or
any(token in mime for token in maybe_json)):
if 'xssi_prefix' in self.kwargs:
token = self.kwargs["xssi_prefix"]
if body[0:len(token)] == token:
body = body[len(token):]
try:
obj = json.loads(body)
except ValueError:
Expand Down
1 change: 1 addition & 0 deletions httpie/output/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def get_stream_type(env, args):
groups=args.prettify,
color_scheme=args.style,
explicit_json=args.json,
xssi_prefix=args.xssi_prefix
),
)
else:
Expand Down

0 comments on commit 6e5f645

Please sign in to comment.