Option to force pretty output on response, regardless of Content-type. #92

Closed
RogWilco opened this Issue Sep 11, 2012 · 9 comments

Projects

None yet

8 participants

@RogWilco

I'm noticing a few places where the response headers are coming back with a Content-type of "text/html" when they actually contain JSON. It would be nice if, in cases like these, you could somehow specify a format to "force" on the response so that the body could still be prettified.

@RogWilco

Ah, I see this is related to #67 which seems to address this very need. Closing ticket...

@RogWilco RogWilco closed this Sep 11, 2012
@RogWilco

Actually, looks like that change didn't make it in. Any chance something similar could be added in? Maybe a way to override the response headers with user-specified values (similar to the headers argument, but for responses)?

@RogWilco RogWilco reopened this Sep 11, 2012
@BM5k

👍
This would be nice to have. Some servers respond with Content-Type: text/html and JSON bodies.

@dequis

FWIW, i'm workarounding invalid content type responses by piping the output to jq

@kfix

see #368

@jkbrzt jkbrzt added a commit that closed this issue Mar 1, 2016
@jkbrzt Added JSON detection when ``--json, -j`` is set
To correctly format JSON responses even when an incorrect ``Content-Type`` is returned.

Closes #92
Closes #349
Closes #368
74e4d0b
@jkbrzt jkbrzt closed this in 74e4d0b Mar 1, 2016
@jkbrzt
Owner

Now with the --json, -j option HTTPie tries to detect JSON responses when the Content-Type is unknown or text/plain.

@dflock

Now with the --json, -j option HTTPie tries to detect JSON responses when the Content-Type is unknown or text/plain.

Right, but there's still no way to force it, so if the Content-Type is text/html but the content is JSON, then you're still out of luck - you have to pipe through jq or something.

Given the number of poorly configured REST API endpoints in the world, having the option to force/override the Content-Type seems like a valid request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment