ccproxy.core.http¶
ccproxy.core.http
¶
Generic HTTP client abstractions for pure forwarding without business logic.
HTTPClient
¶
Bases: ABC
Abstract HTTP client interface for generic HTTP operations.
request
abstractmethod
async
¶
Make an HTTP request.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
method
|
str
|
HTTP method (GET, POST, etc.) |
required |
url
|
str
|
Target URL |
required |
headers
|
dict[str, str]
|
HTTP headers |
required |
body
|
bytes | None
|
Request body (optional) |
None
|
timeout
|
float | None
|
Request timeout in seconds (optional) |
None
|
Returns:
Type | Description |
---|---|
tuple[int, dict[str, str], bytes]
|
Tuple of (status_code, response_headers, response_body) |
Raises:
Type | Description |
---|---|
HTTPError
|
If the request fails |
Source code in ccproxy/core/http.py
BaseProxyClient
¶
Generic proxy client with no business logic - pure forwarding.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
http_client
|
HTTPClient
|
The HTTP client to use for requests |
required |
Source code in ccproxy/core/http.py
forward
async
¶
Forward an HTTP request without any transformations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
method
|
str
|
HTTP method |
required |
url
|
str
|
Target URL |
required |
headers
|
dict[str, str]
|
HTTP headers |
required |
body
|
bytes | None
|
Request body (optional) |
None
|
timeout
|
float | None
|
Request timeout in seconds (optional) |
None
|
Returns:
Type | Description |
---|---|
tuple[int, dict[str, str], bytes]
|
Tuple of (status_code, response_headers, response_body) |
Raises:
Type | Description |
---|---|
HTTPError
|
If the request fails |
Source code in ccproxy/core/http.py
HTTPError
¶
HTTPTimeoutError
¶
HTTPConnectionError
¶
HTTPXClient
¶
Bases: HTTPClient
HTTPX-based HTTP client implementation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
timeout
|
float
|
Request timeout in seconds |
240.0
|
proxy
|
str | None
|
HTTP proxy URL (optional) |
None
|
verify
|
bool | str
|
SSL verification (True/False or path to CA bundle) |
True
|
Source code in ccproxy/core/http.py
request
async
¶
Make an HTTP request using HTTPX.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
method
|
str
|
HTTP method |
required |
url
|
str
|
Target URL |
required |
headers
|
dict[str, str]
|
HTTP headers |
required |
body
|
bytes | None
|
Request body (optional) |
None
|
timeout
|
float | None
|
Request timeout in seconds (optional) |
None
|
Returns:
Type | Description |
---|---|
tuple[int, dict[str, str], bytes]
|
Tuple of (status_code, response_headers, response_body) |
Raises:
Type | Description |
---|---|
HTTPError
|
If the request fails |
Source code in ccproxy/core/http.py
stream
async
¶
Create a streaming HTTP request.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
method
|
str
|
HTTP method |
required |
url
|
str
|
Target URL |
required |
headers
|
dict[str, str]
|
HTTP headers |
required |
content
|
bytes | None
|
Request body (optional) |
None
|
Returns:
Type | Description |
---|---|
Any
|
HTTPX streaming response context manager |
Source code in ccproxy/core/http.py
get_proxy_url
¶
Get proxy URL from environment variables.
Returns:
Type | Description |
---|---|
str | None
|
str or None: Proxy URL if any proxy is set |
Source code in ccproxy/core/http.py
get_ssl_context
¶
Get SSL context configuration from environment variables.
Returns:
Type | Description |
---|---|
str | bool
|
SSL verification configuration: |
str | bool
|
|
str | bool
|
|
str | bool
|
|