```console
$ HTTPX_LOG_LEVEL=debug python test_script.py
-DEBUG [2019-11-06 19:11:24] httpx.client - HTTP Request: GET https://google.com "HTTP/1.1 301 Moved Permanently"
-DEBUG [2019-11-06 19:11:24] httpx.client - HTTP Request: GET https://www.google.com/ "HTTP/1.1 200 OK"
+DEBUG [2019-11-06 19:11:24] httpx._client - HTTP Request: GET https://google.com "HTTP/1.1 301 Moved Permanently"
+DEBUG [2019-11-06 19:11:24] httpx._client - HTTP Request: GET https://www.google.com/ "HTTP/1.1 200 OK"
```
Trace output:
```console
$ HTTPX_LOG_LEVEL=trace python test_script.py
-TRACE [2019-11-06 19:18:56] httpx.dispatch.connection_pool - acquire_connection origin=Origin(scheme='https' host='google.com' port=443)
-TRACE [2019-11-06 19:18:56] httpx.dispatch.connection_pool - new_connection connection=HTTPConnection(origin=Origin(scheme='https' host='google.com' port=443))
-TRACE [2019-11-06 19:18:56] httpx.config - load_ssl_context verify=True cert=None trust_env=True http_versions=HTTPVersionConfig(['HTTP/1.1', 'HTTP/2'])
-TRACE [2019-11-06 19:18:56] httpx.config - load_verify_locations cafile=/Users/florimond/Developer/python-projects/httpx/venv/lib/python3.8/site-packages/certifi/cacert.pem
-TRACE [2019-11-06 19:18:56] httpx.dispatch.connection - start_connect host='google.com' port=443 timeout=Timeout(timeout=5.0)
-TRACE [2019-11-06 19:18:56] httpx.dispatch.connection - connected http_version='HTTP/2'
-TRACE [2019-11-06 19:18:56] httpx.dispatch.http2 - send_headers stream_id=1 method='GET' target='/' headers=[(b':method', b'GET'), (b':authority', b'google.com'), (b':scheme', b'https'), (b':path', b'/'), (b'user-agent', b'python-httpx/0.7.6'), (b'accept', b'*/*'), (b'accept-encoding', b'gzip, deflate, br'), (b'connection', b'keep-alive')]
-TRACE [2019-11-06 19:18:56] httpx.dispatch.http2 - end_stream stream_id=1
-TRACE [2019-11-06 19:18:56] httpx.dispatch.http2 - receive_event stream_id=0 event=<RemoteSettingsChanged changed_settings:{ChangedSetting(setting=SettingCodes.MAX_CONCURRENT_STREAMS, original_value=None, new_value=100), ChangedSetting(setting=SettingCodes.INITIAL_WINDOW_SIZE, original_value=65535, new_value=1048576), ChangedSetting(setting=SettingCodes.MAX_HEADER_LIST_SIZE, original_value=None, new_value=16384)}>
-TRACE [2019-11-06 19:18:56] httpx.dispatch.http2 - receive_event stream_id=0 event=<WindowUpdated stream_id:0, delta:983041>
-TRACE [2019-11-06 19:18:56] httpx.dispatch.http2 - receive_event stream_id=0 event=<SettingsAcknowledged changed_settings:{}>
-TRACE [2019-11-06 19:18:56] httpx.dispatch.http2 - receive_event stream_id=1 event=<ResponseReceived stream_id:1, headers:[(b':status', b'301'), (b'location', b'https://www.google.com/'), (b'content-type', b'text/html; charset=UTF-8'), (b'date', b'Wed, 06 Nov 2019 18:18:56 GMT'), (b'expires', b'Fri, 06 Dec 2019 18:18:56 GMT'), (b'cache-control', b'public, max-age=2592000'), (b'server', b'gws'), (b'content-length', b'220'), (b'x-xss-protection', b'0'), (b'x-frame-options', b'SAMEORIGIN'), (b'alt-svc', b'quic=":443"; ma=2592000; v="46,43",h3-Q050=":443"; ma=2592000,h3-Q049=":443"; ma=2592000,h3-Q048=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000')]>
-DEBUG [2019-11-06 19:18:56] httpx.client - HTTP Request: GET https://google.com "HTTP/2 301 Moved Permanently"
-TRACE [2019-11-06 19:18:56] httpx.dispatch.connection_pool - acquire_connection origin=Origin(scheme='https' host='www.google.com' port=443)
-TRACE [2019-11-06 19:18:56] httpx.dispatch.connection_pool - new_connection connection=HTTPConnection(origin=Origin(scheme='https' host='www.google.com' port=443))
-TRACE [2019-11-06 19:18:56] httpx.config - load_ssl_context verify=True cert=None trust_env=True http_versions=HTTPVersionConfig(['HTTP/1.1', 'HTTP/2'])
-TRACE [2019-11-06 19:18:56] httpx.config - load_verify_locations cafile=/Users/florimond/Developer/python-projects/httpx/venv/lib/python3.8/site-packages/certifi/cacert.pem
-TRACE [2019-11-06 19:18:56] httpx.dispatch.connection - start_connect host='www.google.com' port=443 timeout=Timeout(timeout=5.0)
-TRACE [2019-11-06 19:18:56] httpx.dispatch.connection - connected http_version='HTTP/2'
-TRACE [2019-11-06 19:18:56] httpx.dispatch.http2 - send_headers stream_id=1 method='GET' target='/' headers=[(b':method', b'GET'), (b':authority', b'www.google.com'), (b':scheme', b'https'), (b':path', b'/'), (b'user-agent', b'python-httpx/0.7.6'), (b'accept', b'*/*'), (b'accept-encoding', b'gzip, deflate, br'), (b'connection', b'keep-alive')]
-TRACE [2019-11-06 19:18:56] httpx.dispatch.http2 - end_stream stream_id=1
-TRACE [2019-11-06 19:18:56] httpx.dispatch.http2 - receive_event stream_id=0 event=<RemoteSettingsChanged changed_settings:{ChangedSetting(setting=SettingCodes.MAX_CONCURRENT_STREAMS, original_value=None, new_value=100), ChangedSetting(setting=SettingCodes.INITIAL_WINDOW_SIZE, original_value=65535, new_value=1048576), ChangedSetting(setting=SettingCodes.MAX_HEADER_LIST_SIZE, original_value=None, new_value=16384)}>
-TRACE [2019-11-06 19:18:56] httpx.dispatch.http2 - receive_event stream_id=0 event=<WindowUpdated stream_id:0, delta:983041>
-TRACE [2019-11-06 19:18:56] httpx.dispatch.http2 - receive_event stream_id=0 event=<SettingsAcknowledged changed_settings:{}>
-TRACE [2019-11-06 19:18:56] httpx.dispatch.http2 - receive_event stream_id=1 event=<ResponseReceived stream_id:1, headers:[(b':status', b'200'), (b'date', b'Wed, 06 Nov 2019 18:18:56 GMT'), (b'expires', b'-1'), (b'cache-control', b'private, max-age=0'), (b'content-type', b'text/html; charset=ISO-8859-1'), (b'p3p', b'CP="This is not a P3P policy! See g.co/p3phelp for more info."'), (b'content-encoding', b'gzip'), (b'server', b'gws'), (b'content-length', b'5073'), (b'x-xss-protection', b'0'), (b'x-frame-options', b'SAMEORIGIN'), (b'set-cookie', b'1P_JAR=2019-11-06-18; expires=Fri, 06-Dec-2019 18:18:56 GMT; path=/; domain=.google.com; SameSite=none'), (b'set-cookie', b'NID=190=m8G9qLxCz2_4HbZI02ON2HTJF4xTvOhoJiS57Hm-OJrNS2eY20LfXMR_u-mLjujeshW5-BTezI69OGpHksT4ZK2TCDsWeU0DF7AmDTjjXFOdj30eIUTpNq7r9aWRvI8UrqiwlIsLkE8Ee3t5PiIiVdSMUcji7dkavGlMUpkMXU8; expires=Thu, 07-May-2020 18:18:56 GMT; path=/; domain=.google.com; HttpOnly'), (b'alt-svc', b'quic=":443"; ma=2592000; v="46,43",h3-Q050=":443"; ma=2592000,h3-Q049=":443"; ma=2592000,h3-Q048=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000')]>
-DEBUG [2019-11-06 19:18:56] httpx.client - HTTP Request: GET https://www.google.com/ "HTTP/2 200 OK"
-TRACE [2019-11-06 19:18:56] httpx.dispatch.http2 - receive_event stream_id=1 event=<DataReceived stream_id:1, flow_controlled_length:5186, data:1f8b08000000000002ffc55af97adb4692ff3f4f>
-TRACE [2019-11-06 19:18:56] httpx.dispatch.http2 - receive_event stream_id=1 event=<DataReceived stream_id:1, flow_controlled_length:221, data:>
-TRACE [2019-11-06 19:18:56] httpx.dispatch.http2 - receive_event stream_id=1 event=<StreamEnded stream_id:1>
-TRACE [2019-11-06 19:18:56] httpx.dispatch.http2 - receive_event stream_id=0 event=<PingReceived ping_data:0000000000000000>
-TRACE [2019-11-06 19:18:56] httpx.dispatch.connection_pool - release_connection connection=HTTPConnection(origin=Origin(scheme='https' host='www.google.com' port=443))
-TRACE [2019-11-06 19:18:56] httpx.dispatch.connection - close_connection
+TRACE [2019-11-06 19:18:56] httpx._dispatch.connection_pool - acquire_connection origin=Origin(scheme='https' host='google.com' port=443)
+TRACE [2019-11-06 19:18:56] httpx._dispatch.connection_pool - new_connection connection=HTTPConnection(origin=Origin(scheme='https' host='google.com' port=443))
+TRACE [2019-11-06 19:18:56] httpx._config - load_ssl_context verify=True cert=None trust_env=True http_versions=HTTPVersionConfig(['HTTP/1.1', 'HTTP/2'])
+TRACE [2019-11-06 19:18:56] httpx._config - load_verify_locations cafile=/Users/florimond/Developer/python-projects/httpx/venv/lib/python3.8/site-packages/certifi/cacert.pem
+TRACE [2019-11-06 19:18:56] httpx._dispatch.connection - start_connect host='google.com' port=443 timeout=Timeout(timeout=5.0)
+TRACE [2019-11-06 19:18:56] httpx._dispatch.connection - connected http_version='HTTP/2'
+TRACE [2019-11-06 19:18:56] httpx._dispatch.http2 - send_headers stream_id=1 method='GET' target='/' headers=[(b':method', b'GET'), (b':authority', b'google.com'), (b':scheme', b'https'), (b':path', b'/'), (b'user-agent', b'python-httpx/0.7.6'), (b'accept', b'*/*'), (b'accept-encoding', b'gzip, deflate, br'), (b'connection', b'keep-alive')]
+TRACE [2019-11-06 19:18:56] httpx._dispatch.http2 - end_stream stream_id=1
+TRACE [2019-11-06 19:18:56] httpx._dispatch.http2 - receive_event stream_id=0 event=<RemoteSettingsChanged changed_settings:{ChangedSetting(setting=SettingCodes.MAX_CONCURRENT_STREAMS, original_value=None, new_value=100), ChangedSetting(setting=SettingCodes.INITIAL_WINDOW_SIZE, original_value=65535, new_value=1048576), ChangedSetting(setting=SettingCodes.MAX_HEADER_LIST_SIZE, original_value=None, new_value=16384)}>
+TRACE [2019-11-06 19:18:56] httpx._dispatch.http2 - receive_event stream_id=0 event=<WindowUpdated stream_id:0, delta:983041>
+TRACE [2019-11-06 19:18:56] httpx._dispatch.http2 - receive_event stream_id=0 event=<SettingsAcknowledged changed_settings:{}>
+TRACE [2019-11-06 19:18:56] httpx._dispatch.http2 - receive_event stream_id=1 event=<ResponseReceived stream_id:1, headers:[(b':status', b'301'), (b'location', b'https://www.google.com/'), (b'content-type', b'text/html; charset=UTF-8'), (b'date', b'Wed, 06 Nov 2019 18:18:56 GMT'), (b'expires', b'Fri, 06 Dec 2019 18:18:56 GMT'), (b'cache-control', b'public, max-age=2592000'), (b'server', b'gws'), (b'content-length', b'220'), (b'x-xss-protection', b'0'), (b'x-frame-options', b'SAMEORIGIN'), (b'alt-svc', b'quic=":443"; ma=2592000; v="46,43",h3-Q050=":443"; ma=2592000,h3-Q049=":443"; ma=2592000,h3-Q048=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000')]>
+DEBUG [2019-11-06 19:18:56] httpx._client - HTTP Request: GET https://google.com "HTTP/2 301 Moved Permanently"
+TRACE [2019-11-06 19:18:56] httpx._dispatch.connection_pool - acquire_connection origin=Origin(scheme='https' host='www.google.com' port=443)
+TRACE [2019-11-06 19:18:56] httpx._dispatch.connection_pool - new_connection connection=HTTPConnection(origin=Origin(scheme='https' host='www.google.com' port=443))
+TRACE [2019-11-06 19:18:56] httpx._config - load_ssl_context verify=True cert=None trust_env=True http_versions=HTTPVersionConfig(['HTTP/1.1', 'HTTP/2'])
+TRACE [2019-11-06 19:18:56] httpx._config - load_verify_locations cafile=/Users/florimond/Developer/python-projects/httpx/venv/lib/python3.8/site-packages/certifi/cacert.pem
+TRACE [2019-11-06 19:18:56] httpx._dispatch.connection - start_connect host='www.google.com' port=443 timeout=Timeout(timeout=5.0)
+TRACE [2019-11-06 19:18:56] httpx._dispatch.connection - connected http_version='HTTP/2'
+TRACE [2019-11-06 19:18:56] httpx._dispatch.http2 - send_headers stream_id=1 method='GET' target='/' headers=[(b':method', b'GET'), (b':authority', b'www.google.com'), (b':scheme', b'https'), (b':path', b'/'), (b'user-agent', b'python-httpx/0.7.6'), (b'accept', b'*/*'), (b'accept-encoding', b'gzip, deflate, br'), (b'connection', b'keep-alive')]
+TRACE [2019-11-06 19:18:56] httpx._dispatch.http2 - end_stream stream_id=1
+TRACE [2019-11-06 19:18:56] httpx._dispatch.http2 - receive_event stream_id=0 event=<RemoteSettingsChanged changed_settings:{ChangedSetting(setting=SettingCodes.MAX_CONCURRENT_STREAMS, original_value=None, new_value=100), ChangedSetting(setting=SettingCodes.INITIAL_WINDOW_SIZE, original_value=65535, new_value=1048576), ChangedSetting(setting=SettingCodes.MAX_HEADER_LIST_SIZE, original_value=None, new_value=16384)}>
+TRACE [2019-11-06 19:18:56] httpx._dispatch.http2 - receive_event stream_id=0 event=<WindowUpdated stream_id:0, delta:983041>
+TRACE [2019-11-06 19:18:56] httpx._dispatch.http2 - receive_event stream_id=0 event=<SettingsAcknowledged changed_settings:{}>
+TRACE [2019-11-06 19:18:56] httpx._dispatch.http2 - receive_event stream_id=1 event=<ResponseReceived stream_id:1, headers:[(b':status', b'200'), (b'date', b'Wed, 06 Nov 2019 18:18:56 GMT'), (b'expires', b'-1'), (b'cache-control', b'private, max-age=0'), (b'content-type', b'text/html; charset=ISO-8859-1'), (b'p3p', b'CP="This is not a P3P policy! See g.co/p3phelp for more info."'), (b'content-encoding', b'gzip'), (b'server', b'gws'), (b'content-length', b'5073'), (b'x-xss-protection', b'0'), (b'x-frame-options', b'SAMEORIGIN'), (b'set-cookie', b'1P_JAR=2019-11-06-18; expires=Fri, 06-Dec-2019 18:18:56 GMT; path=/; domain=.google.com; SameSite=none'), (b'set-cookie', b'NID=190=m8G9qLxCz2_4HbZI02ON2HTJF4xTvOhoJiS57Hm-OJrNS2eY20LfXMR_u-mLjujeshW5-BTezI69OGpHksT4ZK2TCDsWeU0DF7AmDTjjXFOdj30eIUTpNq7r9aWRvI8UrqiwlIsLkE8Ee3t5PiIiVdSMUcji7dkavGlMUpkMXU8; expires=Thu, 07-May-2020 18:18:56 GMT; path=/; domain=.google.com; HttpOnly'), (b'alt-svc', b'quic=":443"; ma=2592000; v="46,43",h3-Q050=":443"; ma=2592000,h3-Q049=":443"; ma=2592000,h3-Q048=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000')]>
+DEBUG [2019-11-06 19:18:56] httpx._client - HTTP Request: GET https://www.google.com/ "HTTP/2 200 OK"
+TRACE [2019-11-06 19:18:56] httpx._dispatch.http2 - receive_event stream_id=1 event=<DataReceived stream_id:1, flow_controlled_length:5186, data:1f8b08000000000002ffc55af97adb4692ff3f4f>
+TRACE [2019-11-06 19:18:56] httpx._dispatch.http2 - receive_event stream_id=1 event=<DataReceived stream_id:1, flow_controlled_length:221, data:>
+TRACE [2019-11-06 19:18:56] httpx._dispatch.http2 - receive_event stream_id=1 event=<StreamEnded stream_id:1>
+TRACE [2019-11-06 19:18:56] httpx._dispatch.http2 - receive_event stream_id=0 event=<PingReceived ping_data:0000000000000000>
+TRACE [2019-11-06 19:18:56] httpx._dispatch.connection_pool - release_connection connection=HTTPConnection(origin=Origin(scheme='https' host='www.google.com' port=443))
+TRACE [2019-11-06 19:18:56] httpx._dispatch.connection - close_connection
```
`SSLKEYLOGFILE`
from .__version__ import __description__, __title__, __version__
-from .api import delete, get, head, options, patch, post, put, request, stream
-from .auth import Auth, BasicAuth, DigestAuth
-from .client import AsyncClient, Client
-from .config import PoolLimits, Proxy, Timeout
-from .dispatch.asgi import ASGIDispatch
-from .dispatch.wsgi import WSGIDispatch
-from .exceptions import (
+from ._api import delete, get, head, options, patch, post, put, request, stream
+from ._auth import Auth, BasicAuth, DigestAuth
+from ._client import AsyncClient, Client
+from ._config import PoolLimits, Proxy, Timeout
+from ._dispatch.asgi import ASGIDispatch
+from ._dispatch.wsgi import WSGIDispatch
+from ._exceptions import (
ConnectionClosed,
ConnectTimeout,
CookieConflict,
TooManyRedirects,
WriteTimeout,
)
-from .models import URL, Cookies, Headers, QueryParams, Request, Response
-from .status_codes import StatusCode, codes
+from ._models import URL, Cookies, Headers, QueryParams, Request, Response
+from ._status_codes import StatusCode, codes
__all__ = [
"__description__",
import typing
-from .auth import AuthTypes
-from .client import Client, StreamContextManager
-from .config import DEFAULT_TIMEOUT_CONFIG, CertTypes, TimeoutTypes, VerifyTypes
-from .models import (
+from ._auth import AuthTypes
+from ._client import Client, StreamContextManager
+from ._config import DEFAULT_TIMEOUT_CONFIG, CertTypes, TimeoutTypes, VerifyTypes
+from ._models import (
CookieTypes,
HeaderTypes,
QueryParamTypes,
from base64 import b64encode
from urllib.request import parse_http_list
-from .exceptions import ProtocolError, RequestBodyUnavailable
-from .models import Request, Response
-from .utils import to_bytes, to_str, unquote
+from ._exceptions import ProtocolError, RequestBodyUnavailable
+from ._models import Request, Response
+from ._utils import to_bytes, to_str, unquote
AuthTypes = typing.Union[
typing.Tuple[typing.Union[str, bytes], typing.Union[str, bytes]],
import ssl
import typing
-from ..config import Timeout
-from ..exceptions import ConnectTimeout, ReadTimeout, WriteTimeout
-from ..utils import as_network_error
+from .._config import Timeout
+from .._exceptions import ConnectTimeout, ReadTimeout, WriteTimeout
+from .._utils import as_network_error
from .base import BaseLock, BaseSemaphore, BaseSocketStream, ConcurrencyBackend
SSL_MONKEY_PATCH_APPLIED = False
import sniffio
-from ..config import Timeout
+from .._config import Timeout
from .base import (
BaseLock,
BaseSemaphore,
import typing
from types import TracebackType
-from ..config import Timeout
+from .._config import Timeout
def lookup_backend(
import trio
-from ..config import Timeout
-from ..exceptions import ConnectTimeout, ReadTimeout, WriteTimeout
-from ..utils import as_network_error
+from .._config import Timeout
+from .._exceptions import ConnectTimeout, ReadTimeout, WriteTimeout
+from .._utils import as_network_error
from .base import BaseLock, BaseSemaphore, BaseSocketStream, ConcurrencyBackend
import hstspreload
-from .auth import Auth, AuthTypes, BasicAuth, FunctionAuth
-from .backends.base import ConcurrencyBackend
-from .config import (
+from ._auth import Auth, AuthTypes, BasicAuth, FunctionAuth
+from ._backends.base import ConcurrencyBackend
+from ._config import (
DEFAULT_MAX_REDIRECTS,
DEFAULT_POOL_LIMITS,
DEFAULT_TIMEOUT_CONFIG,
UnsetType,
VerifyTypes,
)
-from .content_streams import ContentStream
-from .dispatch.asgi import ASGIDispatch
-from .dispatch.base import AsyncDispatcher, SyncDispatcher
-from .dispatch.connection_pool import ConnectionPool
-from .dispatch.proxy_http import HTTPProxy
-from .dispatch.urllib3 import URLLib3Dispatcher
-from .dispatch.wsgi import WSGIDispatch
-from .exceptions import (
+from ._content_streams import ContentStream
+from ._dispatch.asgi import ASGIDispatch
+from ._dispatch.base import AsyncDispatcher, SyncDispatcher
+from ._dispatch.connection_pool import ConnectionPool
+from ._dispatch.proxy_http import HTTPProxy
+from ._dispatch.urllib3 import URLLib3Dispatcher
+from ._dispatch.wsgi import WSGIDispatch
+from ._exceptions import (
HTTPError,
InvalidURL,
RedirectLoop,
RequestBodyUnavailable,
TooManyRedirects,
)
-from .models import (
+from ._models import (
URL,
Cookies,
CookieTypes,
Response,
URLTypes,
)
-from .status_codes import codes
-from .utils import NetRCInfo, get_environment_proxies, get_logger
+from ._status_codes import codes
+from ._utils import NetRCInfo, get_environment_proxies, get_logger
logger = get_logger(__name__)
import certifi
-from .models import URL, Headers, HeaderTypes, URLTypes
-from .utils import get_ca_bundle_from_env, get_logger
+from ._models import URL, Headers, HeaderTypes, URLTypes
+from ._utils import get_ca_bundle_from_env, get_logger
CertTypes = typing.Union[str, typing.Tuple[str, str], typing.Tuple[str, str, str]]
VerifyTypes = typing.Union[str, bool, ssl.SSLContext]
from pathlib import Path
from urllib.parse import urlencode
-from .exceptions import StreamConsumed
-from .utils import format_form_param
+from ._exceptions import StreamConsumed
+from ._utils import format_form_param
RequestData = typing.Union[
dict, str, bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]
import chardet
-from .exceptions import DecodingError
+from ._exceptions import DecodingError
try:
import brotli
import typing
-from ..config import TimeoutTypes
-from ..content_streams import ByteStream
-from ..models import Request, Response
+from .._config import TimeoutTypes
+from .._content_streams import ByteStream
+from .._models import Request, Response
from .base import AsyncDispatcher
import typing
from types import TracebackType
-from ..config import Timeout
-from ..models import (
+from .._config import Timeout
+from .._models import (
HeaderTypes,
QueryParamTypes,
Request,
import h11
-from ..backends.base import ConcurrencyBackend, lookup_backend
-from ..config import SSLConfig, Timeout
-from ..models import URL, Origin, Request, Response
-from ..utils import get_logger
+from .._backends.base import ConcurrencyBackend, lookup_backend
+from .._config import SSLConfig, Timeout
+from .._models import URL, Origin, Request, Response
+from .._utils import get_logger
from .base import AsyncDispatcher
from .http2 import HTTP2Connection
from .http11 import HTTP11Connection
import typing
-from ..backends.base import BaseSemaphore, ConcurrencyBackend, lookup_backend
-from ..config import (
+from .._backends.base import BaseSemaphore, ConcurrencyBackend, lookup_backend
+from .._config import (
DEFAULT_POOL_LIMITS,
CertTypes,
PoolLimits,
Timeout,
VerifyTypes,
)
-from ..exceptions import PoolTimeout
-from ..models import Origin, Request, Response
-from ..utils import get_logger
+from .._exceptions import PoolTimeout
+from .._models import Origin, Request, Response
+from .._utils import get_logger
from .base import AsyncDispatcher
from .connection import HTTPConnection
import h11
-from ..backends.base import BaseSocketStream
-from ..config import Timeout
-from ..content_streams import AsyncIteratorStream
-from ..exceptions import ConnectionClosed, ProtocolError
-from ..models import Request, Response
-from ..utils import get_logger
+from .._backends.base import BaseSocketStream
+from .._config import Timeout
+from .._content_streams import AsyncIteratorStream
+from .._exceptions import ConnectionClosed, ProtocolError
+from .._models import Request, Response
+from .._utils import get_logger
H11Event = typing.Union[
h11.Request,
from h2.config import H2Configuration
from h2.settings import SettingCodes, Settings
-from ..backends.base import (
+from .._backends.base import (
BaseLock,
BaseSocketStream,
ConcurrencyBackend,
lookup_backend,
)
-from ..config import Timeout
-from ..content_streams import AsyncIteratorStream
-from ..exceptions import ProtocolError
-from ..models import Request, Response
-from ..utils import get_logger
+from .._config import Timeout
+from .._content_streams import AsyncIteratorStream
+from .._exceptions import ProtocolError
+from .._models import Request, Response
+from .._utils import get_logger
logger = get_logger(__name__)
import warnings
from base64 import b64encode
-from ..backends.base import ConcurrencyBackend
-from ..config import (
+from .._backends.base import ConcurrencyBackend
+from .._config import (
DEFAULT_POOL_LIMITS,
CertTypes,
PoolLimits,
Timeout,
VerifyTypes,
)
-from ..exceptions import ProxyError
-from ..models import URL, Headers, HeaderTypes, Origin, Request, Response, URLTypes
-from ..utils import get_logger
+from .._exceptions import ProxyError
+from .._models import URL, Headers, HeaderTypes, Origin, Request, Response, URLTypes
+from .._utils import get_logger
from .connection import HTTPConnection
from .connection_pool import ConnectionPool
import urllib3
from urllib3.exceptions import MaxRetryError, SSLError
-from ..config import (
+from .._config import (
DEFAULT_POOL_LIMITS,
CertTypes,
PoolLimits,
Timeout,
VerifyTypes,
)
-from ..content_streams import IteratorStream
-from ..models import Request, Response
-from ..utils import as_network_error
+from .._content_streams import IteratorStream
+from .._models import Request, Response
+from .._utils import as_network_error
from .base import SyncDispatcher
import io
import typing
-from ..config import TimeoutTypes
-from ..content_streams import IteratorStream
-from ..models import Request, Response
+from .._config import TimeoutTypes
+from .._content_streams import IteratorStream
+from .._models import Request, Response
from .base import SyncDispatcher
import typing
if typing.TYPE_CHECKING:
- from .models import Request, Response # pragma: nocover
+ from ._models import Request, Response # pragma: nocover
class HTTPError(Exception):
import rfc3986
from .__version__ import __version__
-from .content_streams import (
+from ._content_streams import (
ByteStream,
ContentStream,
RequestData,
RequestFiles,
encode,
)
-from .decoders import (
+from ._decoders import (
SUPPORTED_DECODERS,
Decoder,
IdentityDecoder,
MultiDecoder,
TextDecoder,
)
-from .exceptions import (
+from ._exceptions import (
CookieConflict,
HTTPError,
InvalidURL,
ResponseNotRead,
StreamConsumed,
)
-from .status_codes import StatusCode
-from .utils import (
+from ._status_codes import StatusCode
+from ._utils import (
ElapsedTimer,
flatten_queryparams,
guess_json_utf,
)
if typing.TYPE_CHECKING: # pragma: no cover
- from .dispatch.base import AsyncDispatcher # noqa: F401
+ from ._dispatch.base import AsyncDispatcher # noqa: F401
PrimitiveData = typing.Optional[typing.Union[str, int, float, bool]]
from types import TracebackType
from urllib.request import getproxies
-from .exceptions import NetworkError
+from ._exceptions import NetworkError
if typing.TYPE_CHECKING: # pragma: no cover
- from .models import PrimitiveData
- from .models import URL
+ from ._models import PrimitiveData
+ from ._models import URL
_HTML5_FORM_ENCODING_REPLACEMENTS = {'"': "%22", "\\": "\\\\"}
RequestBodyUnavailable,
Response,
)
-from httpx.config import CertTypes, TimeoutTypes, VerifyTypes
-from httpx.dispatch.base import AsyncDispatcher
+from httpx._config import CertTypes, TimeoutTypes, VerifyTypes
+from httpx._dispatch.base import AsyncDispatcher
class MockDispatch(AsyncDispatcher):
import pytest
from httpx import AsyncClient, Cookies, Request, Response
-from httpx.config import CertTypes, TimeoutTypes, VerifyTypes
-from httpx.dispatch.base import AsyncDispatcher
+from httpx._config import CertTypes, TimeoutTypes, VerifyTypes
+from httpx._dispatch.base import AsyncDispatcher
class MockDispatch(AsyncDispatcher):
import pytest
from httpx import AsyncClient, Headers, Request, Response, __version__
-from httpx.config import CertTypes, TimeoutTypes, VerifyTypes
-from httpx.dispatch.base import AsyncDispatcher
+from httpx._config import CertTypes, TimeoutTypes, VerifyTypes
+from httpx._dispatch.base import AsyncDispatcher
class MockDispatch(AsyncDispatcher):
import pytest
from httpx import URL, AsyncClient, QueryParams, Request, Response
-from httpx.config import CertTypes, TimeoutTypes, VerifyTypes
-from httpx.dispatch.base import AsyncDispatcher
+from httpx._config import CertTypes, TimeoutTypes, VerifyTypes
+from httpx._dispatch.base import AsyncDispatcher
class MockDispatch(AsyncDispatcher):
TooManyRedirects,
codes,
)
-from httpx.config import CertTypes, TimeoutTypes, VerifyTypes
-from httpx.content_streams import AsyncIteratorStream
-from httpx.dispatch.base import AsyncDispatcher
+from httpx._config import CertTypes, TimeoutTypes, VerifyTypes
+from httpx._content_streams import AsyncIteratorStream
+from httpx._dispatch.base import AsyncDispatcher
class MockDispatch(AsyncDispatcher):
import pytest
import httpx
-from httpx.dispatch.connection_pool import ConnectionPool
+from httpx._dispatch.connection_pool import ConnectionPool
@pytest.mark.usefixtures("async_environment")
import pytest
import httpx
-from httpx.config import SSLConfig
-from httpx.dispatch.connection import HTTPConnection
+from httpx._config import SSLConfig
+from httpx._dispatch.connection import HTTPConnection
@pytest.mark.usefixtures("async_environment")
import pytest
import httpx
-from httpx.dispatch.proxy_http import HTTPProxy
+from httpx._dispatch.proxy_http import HTTPProxy
from .utils import MockRawSocketBackend
import h2.events
from httpx import Request, Timeout
-from httpx.backends.base import BaseSocketStream, lookup_backend
+from httpx._backends.base import BaseSocketStream, lookup_backend
class MockHTTP2Backend:
import pytest
import httpx
-from httpx.content_streams import AsyncIteratorStream, IteratorStream
+from httpx._content_streams import AsyncIteratorStream, IteratorStream
REQUEST = httpx.Request("GET", "https://example.org")
content = json.dumps(data).encode("utf-32-be")
headers = {"Content-Type": "application/json"}
# force incorrect guess from `guess_json_utf` to trigger error
- with mock.patch("httpx.models.guess_json_utf", return_value="utf-32"):
+ with mock.patch("httpx._models.guess_json_utf", return_value="utf-32"):
response = httpx.Response(
200, content=content, headers=headers, request=REQUEST
)
import pytest
from httpx import URL, InvalidURL
-from httpx.models import Origin
+from httpx._models import Origin
@pytest.mark.parametrize(
import trio
from httpx import Timeout
-from httpx.backends.asyncio import AsyncioBackend
-from httpx.backends.base import lookup_backend
-from httpx.backends.trio import TrioBackend
-from httpx.config import SSLConfig
+from httpx._backends.asyncio import AsyncioBackend
+from httpx._backends.base import lookup_backend
+from httpx._backends.trio import TrioBackend
+from httpx._config import SSLConfig
from tests.concurrency import get_cipher, run_concurrently
import pytest
import httpx
-from httpx.config import SSLConfig
+from httpx._config import SSLConfig
def test_load_ssl_config():
import pytest
-from httpx.content_streams import ContentStream, encode
-from httpx.exceptions import StreamConsumed
+from httpx import StreamConsumed
+from httpx._content_streams import ContentStream, encode
@pytest.mark.asyncio
import pytest
import httpx
-from httpx.content_streams import AsyncIteratorStream
-from httpx.decoders import (
+from httpx._content_streams import AsyncIteratorStream
+from httpx._decoders import (
BrotliDecoder,
DeflateDecoder,
GZipDecoder,
import pytest
import httpx
-from httpx.config import CertTypes, TimeoutTypes, VerifyTypes
-from httpx.content_streams import encode
-from httpx.dispatch.base import AsyncDispatcher
-from httpx.utils import format_form_param
+from httpx._config import CertTypes, TimeoutTypes, VerifyTypes
+from httpx._content_streams import encode
+from httpx._dispatch.base import AsyncDispatcher
+from httpx._utils import format_form_param
class MockDispatch(AsyncDispatcher):
import pytest
import httpx
-from httpx.utils import (
+from httpx._utils import (
ElapsedTimer,
NetRCInfo,
get_ca_bundle_from_env,
assert response.status_code == 200
stderr = capsys.readouterr().err
assert 'HTTP Request: GET http://127.0.0.1:8000/ "HTTP/1.1 200 OK"' in stderr
- assert "httpx.dispatch.connection_pool" not in stderr
+ assert "httpx._dispatch.connection_pool" not in stderr
@pytest.mark.asyncio
assert response.status_code == 200
stderr = capsys.readouterr().err
assert 'HTTP Request: GET http://127.0.0.1:8000/ "HTTP/1.1 200 OK"' in stderr
- assert "httpx.dispatch.connection_pool" in stderr
+ assert "httpx._dispatch.connection_pool" in stderr
@pytest.mark.asyncio
)
def test_should_not_be_proxied(url, no_proxy, expected):
os.environ.update(no_proxy)
- parsed_url = httpx.models.URL(url)
+ parsed_url = httpx.URL(url)
assert should_not_be_proxied(parsed_url) == expected
import logging
import os
-from httpx import utils
+from httpx import _utils
@contextlib.contextmanager
os.environ["HTTPX_LOG_LEVEL"] = log_level
# Force a reload on the logging handlers
- utils._LOGGER_INITIALIZED = False
- utils.get_logger("httpx")
+ _utils._LOGGER_INITIALIZED = False
+ _utils.get_logger("httpx")
try:
yield