New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python API #551
Comments
Yes, it makes sense — I'll look into this. |
@eliangcs I'm doing a bigger refactoring and I'm thinking it would be good to have a stable and documented Could you maybe flash something out based on what // cc @mblayman |
@jkbrzt I did a grep over my codebase. These are what I found: # http_prompt/cli.py
from httpie.plugins import FormatterPlugin # just to avoid cyclic import, not really used
from httpie.output.formatters.colors import Solarized256Style # to support solarized theme
# http_prompt/execution.py
from httpie.context import Environment # to construct a custom Environment and pass it to httpie_main
from httpie.core import main as httpie_main # to generate output and the response object |
HTTPony touches very little of HTTPie's APIs. It's limited to: from httpie.cli import parser
from httpie.context import Environment
from httpie.output import streams The core of what is done is passing a |
Great, thanks. I'll go through it and to formalize those things where it makes sense. Then make some wrappers in This will make it explicit users can/might depend on it and provide some guarantee of stability compared to the internals. Changes to the |
HTTP Prompt* heavily relies on
httpie.core.main()
function to send actual HTTP requests. Some HTTP Prompt's features, like setting incoming cookies, require us to access the response object (requests.Response
, to be more specific) in Python, buthttpie.core.main()
doesn't provide such an API. So HTTP Prompt "hacks" HTTPie withsys.settrace()
to get the response object returned byhttpie.core.get_response()
, as the following code shows:https://github.com/eliangcs/http-prompt/blob/cbd092299/http_prompt/execution.py#L430
I wonder if HTTPie could offer an API for developers to access the internal response object easier.
* For those who haven't already known: HTTP Prompt is a wrapper that provides an interactive interface of HTTPie.
The text was updated successfully, but these errors were encountered: