question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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, but httpie.core.main() doesn’t provide such an API. So HTTP Prompt “hacks” HTTPie with sys.settrace() to get the response object returned by httpie.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.

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:2
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
mblaymancommented, Mar 8, 2017

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 requests.models.Request to streams.build_output_stream and calling streams.write_stream. All that happens in https://github.com/mblayman/httpony/blob/master/httpony/application.py.

2reactions
jakubroztocilcommented, Mar 2, 2017

Yes, it makes sense — I’ll look into this. main() could return both exit status code and the final HTTP response. And maybe the parse args as well would be useful to return as well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python API Tutorial: Getting Started with APIs - Dataquest
An API, or Application Programming Interface, is a server that you can use to retrieve and send data to using code. APIs are...
Read more >
Python/C API Reference Manual — Python 3.11.1 ...
This manual documents the API used by C and C++ programmers who want to write extension modules or embed Python. It is a...
Read more >
Python & APIs: A Winning Combo for Reading Public Data
API stands for application programming interface. In essence, an API acts as a communication layer, or as the name says, an interface, that...
Read more >
How to use an API with Python (Beginner's Guide) - RapidAPI
An API (Application Programming Interface) is a set of rules that are shared by a particular service. These rules determine in which format...
Read more >
Python API Development - Comprehensive Course ... - YouTube
Learn Python API development in one of the most comprehensive courses ever on the topic. You will build a full-fledged API in Python...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found