Feature request: output full HTTP request and response in a JSON structure
See original GitHub issueI would love to capture the full HTTP request and response in a JSON structure so I can extract the various parts programmatically without parsing the plaintext output.
For example:
http --output-full-json ...
{
"request": {
"headers": "Accept: application/json\r\nContent-Type: application/json",
"body": "<request body here, escaped/encoded as necessary to work as a string value>"
},
"response": {
"headers": "201 Created\r\nContent-Type: application/json\r\nContent-Length: 42",
"body": "<response body here, escaped/encoded as necessary to work as a string value>"
}
}
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:7 (2 by maintainers)
Top Results From Across the Web
JSON requests and responses - Atlassian Developer
To make a request with JSON, the appropriate HTTP headers are: ... the following command attempts to authenticate a user by password with...
Read more >response.json() - Python requests - GeeksforGeeks
response.json() returns a JSON object of the result (if the result was written in JSON format, if not it raises an error). Python...
Read more >Request and Response JSON Reference | Alexa Skills Kit
The request body sent to your service is in JSON format. In this example, the AudioPlayer directive has been requested, but the Display.RenderTemplate...
Read more >Python requests response print in JSON format U' is added to ...
You can use encode() method to convert unicode strings to ascii strings like this : import requests import json headers={ "accept": ...
Read more >Working with JSON - Learn web development | MDN
JavaScript Object Notation (JSON) is a standard text-based format for ... request using the fetch() function, and this returns a Response ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for the suggestion, @hughpv. I’ve been considering this for a while.
Initial thoughts
--all
, anArray
of exchanges is printed instead of a single object.--output-format
which could beraw
(default) +json
+ potentially more in the future.jq
but consider supporting simple selectors directly. Something like--select=response.headers.content-type
. These would work on the JSON structure so when used, then--output-format=json
would be implied. Need to consider the multi-exchange scenario (where index might be needed).Hypothetical example
Correct. 😃 But I could definitely see where some users would find structured headers quite useful.