+from .__version__ import __description__, __title__, __version__
from .api import delete, get, head, options, patch, post, put, request
from .client import AsyncClient, Client
from .concurrency import AsyncioBackend
from .config import (
+ USER_AGENT,
CertTypes,
PoolLimits,
SSLConfig,
from .models import (
URL,
AsyncRequest,
+ AsyncRequestData,
AsyncResponse,
+ AsyncResponseContent,
+ AuthTypes,
Cookies,
+ CookieTypes,
Headers,
+ HeaderTypes,
Origin,
QueryParams,
+ QueryParamTypes,
Request,
+ RequestData,
+ RequestFiles,
Response,
+ ResponseContent,
+ URLTypes,
)
from .status_codes import StatusCode, codes
-
-__version__ = "0.6.5"
--- /dev/null
+__title__ = "http3"
+__description__ = "A next generation HTTP client, for Python 3."
+__version__ = "0.6.6"
from .dispatch.connection_pool import ConnectionPool
from .dispatch.threaded import ThreadedDispatcher
from .dispatch.wsgi import WSGIDispatch
-from .exceptions import RedirectBodyUnavailable, RedirectLoop, TooManyRedirects
+from .exceptions import (
+ InvalidURL,
+ RedirectBodyUnavailable,
+ RedirectLoop,
+ TooManyRedirects,
+)
from .interfaces import AsyncDispatcher, ConcurrencyBackend, Dispatcher
from .models import (
URL,
auth = self.auth
url = request.url
+
+ if url.scheme not in ("http", "https"):
+ raise InvalidURL('URL scheme must be "http" or "https".')
+
if auth is None and (url.username or url.password):
auth = HTTPBasicAuth(username=url.username, password=url.password)
import certifi
+from .__version__ import __version__
+
CertTypes = typing.Union[str, typing.Tuple[str, str]]
VerifyTypes = typing.Union[str, bool]
TimeoutTypes = typing.Union[float, typing.Tuple[float, float, float], "TimeoutConfig"]
+USER_AGENT = f"python-http3/{__version__}"
+
DEFAULT_CIPHERS = ":".join(
[
"ECDHE+AESGCM",
import chardet
import rfc3986
+from .config import USER_AGENT
from .decoders import (
ACCEPT_ENCODING,
SUPPORTED_DECODERS,
if not allow_relative:
if not self.scheme:
raise InvalidURL("No scheme included in URL.")
- if self.scheme not in ("http", "https"):
- raise InvalidURL('URL scheme must be "http" or "https".')
if not self.host:
raise InvalidURL("No host included in URL.")
"content-length" in self.headers or "transfer-encoding" in self.headers
)
has_accept_encoding = "accept-encoding" in self.headers
+ has_connection = "connection" in self.headers
if not has_host:
auto_headers.append((b"host", self.url.authority.encode("ascii")))
if not has_user_agent:
- auto_headers.append((b"user-agent", b"http3"))
+ auto_headers.append((b"user-agent", USER_AGENT.encode("ascii")))
if not has_accept:
auto_headers.append((b"accept", b"*/*"))
if not has_content_length:
auto_headers.append((b"content-length", content_length))
if not has_accept_encoding:
auto_headers.append((b"accept-encoding", ACCEPT_ENCODING.encode()))
+ if not has_connection:
+ auto_headers.append((b"connection", b"keep-alive"))
for item in reversed(auto_headers):
self.headers.raw.insert(0, item)
#!/bin/sh -e
export PACKAGE="http3"
-export VERSION=`cat ${PACKAGE}/__init__.py | grep __version__ | sed "s/__version__ = //" | sed "s/'//g"`
+export VERSION=`cat ${PACKAGE}/__version__.py | grep __version__ | sed "s/__version__ = //" | sed "s/'//g"`
export PREFIX=""
if [ -d 'venv' ] ; then
export PREFIX="venv/bin/"
with pytest.raises(http3.InvalidURL):
http3.Request("GET", "example.org")
- with pytest.raises(http3.InvalidURL):
- http3.Request("GET", "invalid://example.org")
-
with pytest.raises(http3.InvalidURL):
http3.Request("GET", "http:///foo")
response = http3.delete("http://127.0.0.1:8000/")
assert response.status_code == 200
assert response.reason_phrase == "OK"
+
+
+@threadpool
+def test_get_invalid_url(server):
+ with pytest.raises(http3.InvalidURL):
+ http3.get("invalid://example.org")