|
1 | | -# Contribution Guidelines |
2 | | - |
3 | | -Before opening any issues or proposing any pull requests, please read |
4 | | -our [Contributor's Guide](https://requests.readthedocs.io/en/latest/dev/contributing/). |
5 | | - |
6 | | -To get the greatest chance of helpful responses, please also observe the |
7 | | -following additional notes. |
8 | | - |
9 | | -## Questions |
10 | | - |
11 | | -The GitHub issue tracker is for *bug reports* and *feature requests*. Please do |
12 | | -not use it to ask questions about how to use Requests. These questions should |
13 | | -instead be directed to [Stack Overflow](https://stackoverflow.com/). Make sure |
14 | | -that your question is tagged with the `python-requests` tag when asking it on |
15 | | -Stack Overflow, to ensure that it is answered promptly and accurately. |
16 | | - |
17 | | -## Good Bug Reports |
18 | | - |
19 | | -Please be aware of the following things when filing bug reports: |
20 | | - |
21 | | -1. Avoid raising duplicate issues. *Please* use the GitHub issue search feature |
22 | | - to check whether your bug report or feature request has been mentioned in |
23 | | - the past. Duplicate bug reports and feature requests are a huge maintenance |
24 | | - burden on the limited resources of the project. If it is clear from your |
25 | | - report that you would have struggled to find the original, that's ok, but |
26 | | - if searching for a selection of words in your issue title would have found |
27 | | - the duplicate then the issue will likely be closed extremely abruptly. |
28 | | -2. When filing bug reports about exceptions or tracebacks, please include the |
29 | | - *complete* traceback. Partial tracebacks, or just the exception text, are |
30 | | - not helpful. Issues that do not contain complete tracebacks may be closed |
31 | | - without warning. |
32 | | -3. Make sure you provide a suitable amount of information to work with. This |
33 | | - means you should provide: |
34 | | - |
35 | | - - Guidance on **how to reproduce the issue**. Ideally, this should be a |
36 | | - *small* code sample that can be run immediately by the maintainers. |
37 | | - Failing that, let us know what you're doing, how often it happens, what |
38 | | - environment you're using, etc. Be thorough: it prevents us needing to ask |
39 | | - further questions. |
40 | | - - Tell us **what you expected to happen**. When we run your example code, |
41 | | - what are we expecting to happen? What does "success" look like for your |
42 | | - code? |
43 | | - - Tell us **what actually happens**. It's not helpful for you to say "it |
44 | | - doesn't work" or "it fails". Tell us *how* it fails: do you get an |
45 | | - exception? A hang? A non-200 status code? How was the actual result |
46 | | - different from your expected result? |
47 | | - - Tell us **what version of Requests you're using**, and |
48 | | - **how you installed it**. Different versions of Requests behave |
49 | | - differently and have different bugs, and some distributors of Requests |
50 | | - ship patches on top of the code we supply. |
51 | | - |
52 | | - If you do not provide all of these things, it will take us much longer to |
53 | | - fix your problem. If we ask you to clarify these and you never respond, we |
54 | | - will close your issue without fixing it. |
| 1 | +# HTTP Core |
| 2 | + |
| 3 | +[](https://github.com/encode/httpcore/actions) |
| 4 | +[](https://pypi.org/project/httpcore/) |
| 5 | + |
| 6 | +> *Do one thing, and do it well.* |
| 7 | +
|
| 8 | +The HTTP Core package provides a minimal low-level HTTP client, which does |
| 9 | +one thing only. Sending HTTP requests. |
| 10 | + |
| 11 | +It does not provide any high level model abstractions over the API, |
| 12 | +does not handle redirects, multipart uploads, building authentication headers, |
| 13 | +transparent HTTP caching, URL parsing, session cookie handling, |
| 14 | +content or charset decoding, handling JSON, environment based configuration |
| 15 | +defaults, or any of that Jazz. |
| 16 | + |
| 17 | +Some things HTTP Core does do: |
| 18 | + |
| 19 | +* Sending HTTP requests. |
| 20 | +* Thread-safe / task-safe connection pooling. |
| 21 | +* HTTP(S) proxy & SOCKS proxy support. |
| 22 | +* Supports HTTP/1.1 and HTTP/2. |
| 23 | +* Provides both sync and async interfaces. |
| 24 | +* Async backend support for `asyncio` and `trio`. |
| 25 | + |
| 26 | +## Requirements |
| 27 | + |
| 28 | +Python 3.8+ |
| 29 | + |
| 30 | +## Installation |
| 31 | + |
| 32 | +For HTTP/1.1 only support, install with: |
| 33 | + |
| 34 | +```shell |
| 35 | +$ pip install httpcore |
| 36 | +``` |
| 37 | + |
| 38 | +There are also a number of optional extras available... |
| 39 | + |
| 40 | +```shell |
| 41 | +$ pip install httpcore['asyncio,trio,http2,socks'] |
| 42 | +``` |
| 43 | + |
| 44 | +## Sending requests |
| 45 | + |
| 46 | +Send an HTTP request: |
| 47 | + |
| 48 | +```python |
| 49 | +import httpcore |
| 50 | + |
| 51 | +response = httpcore.request("GET", "https://www.example.com/") |
| 52 | + |
| 53 | +print(response) |
| 54 | +# <Response [200]> |
| 55 | +print(response.status) |
| 56 | +# 200 |
| 57 | +print(response.headers) |
| 58 | +# [(b'Accept-Ranges', b'bytes'), (b'Age', b'557328'), (b'Cache-Control', b'max-age=604800'), ...] |
| 59 | +print(response.content) |
| 60 | +# b'<!doctype html>\n<html>\n<head>\n<title>Example Domain</title>\n\n<meta charset="utf-8"/>\n ...' |
| 61 | +``` |
| 62 | + |
| 63 | +The top-level `httpcore.request()` function is provided for convenience. In practice whenever you're working with `httpcore` you'll want to use the connection pooling functionality that it provides. |
| 64 | + |
| 65 | +```python |
| 66 | +import httpcore |
| 67 | + |
| 68 | +http = httpcore.ConnectionPool() |
| 69 | +response = http.request("GET", "https://www.example.com/") |
| 70 | +``` |
| 71 | + |
| 72 | +Once you're ready to get going, [head over to the documentation](https://www.encode.io/httpcore/). |
| 73 | + |
| 74 | +## Motivation |
| 75 | + |
| 76 | +You *probably* don't want to be using HTTP Core directly. It might make sense if |
| 77 | +you're writing something like a proxy service in Python, and you just want |
| 78 | +something at the lowest possible level, but more typically you'll want to use |
| 79 | +a higher level client library, such as `httpx`. |
| 80 | + |
| 81 | +The motivation for `httpcore` is: |
| 82 | + |
| 83 | +* To provide a reusable low-level client library, that other packages can then build on top of. |
| 84 | +* To provide a *really clear interface split* between the networking code and client logic, |
| 85 | + so that each is easier to understand and reason about in isolation. |
| 86 | + |
| 87 | +## Dependencies |
| 88 | + |
| 89 | +The `httpcore` package has the following dependencies... |
| 90 | + |
| 91 | +* `h11` |
| 92 | +* `certifi` |
| 93 | + |
| 94 | +And the following optional extras... |
| 95 | + |
| 96 | +* `anyio` - Required by `pip install httpcore['asyncio']`. |
| 97 | +* `trio` - Required by `pip install httpcore['trio']`. |
| 98 | +* `h2` - Required by `pip install httpcore['http2']`. |
| 99 | +* `socksio` - Required by `pip install httpcore['socks']`. |
| 100 | + |
| 101 | +## Versioning |
| 102 | + |
| 103 | +We use [SEMVER for our versioning policy](https://semver.org/). |
| 104 | + |
| 105 | +For changes between package versions please see our [project changelog](CHANGELOG.md). |
| 106 | + |
| 107 | +We recommend pinning your requirements either the most current major version, or a more specific version range: |
| 108 | + |
| 109 | +```python |
| 110 | +pip install 'httpcore==1.*' |
| 111 | +``` |
0 commit comments