smithy-http 0.3.0__tar.gz → 0.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- smithy_http-0.4.0/.changes/0.3.1.json +12 -0
- smithy_http-0.4.0/.changes/0.4.0.json +12 -0
- {smithy_http-0.3.0 → smithy_http-0.4.0}/CHANGELOG.md +16 -0
- {smithy_http-0.3.0 → smithy_http-0.4.0}/PKG-INFO +3 -3
- {smithy_http-0.3.0 → smithy_http-0.4.0}/pyproject.toml +2 -2
- {smithy_http-0.3.0 → smithy_http-0.4.0}/src/smithy_http/__init__.py +10 -7
- {smithy_http-0.3.0 → smithy_http-0.4.0}/src/smithy_http/aio/aiohttp.py +1 -2
- {smithy_http-0.3.0 → smithy_http-0.4.0}/src/smithy_http/aio/crt.py +3 -5
- {smithy_http-0.3.0 → smithy_http-0.4.0}/src/smithy_http/interfaces/__init__.py +9 -20
- {smithy_http-0.3.0 → smithy_http-0.4.0}/src/smithy_http/serializers.py +1 -1
- {smithy_http-0.3.0 → smithy_http-0.4.0}/.changes/0.0.1.json +0 -0
- {smithy_http-0.3.0 → smithy_http-0.4.0}/.changes/0.1.0.json +0 -0
- {smithy_http-0.3.0 → smithy_http-0.4.0}/.changes/0.2.0.json +0 -0
- {smithy_http-0.3.0 → smithy_http-0.4.0}/.changes/0.2.1.json +0 -0
- {smithy_http-0.3.0 → smithy_http-0.4.0}/.changes/0.3.0.json +0 -0
- {smithy_http-0.3.0 → smithy_http-0.4.0}/.gitignore +0 -0
- {smithy_http-0.3.0 → smithy_http-0.4.0}/NOTICE +0 -0
- {smithy_http-0.3.0 → smithy_http-0.4.0}/README.md +0 -0
- {smithy_http-0.3.0 → smithy_http-0.4.0}/src/smithy_http/aio/__init__.py +0 -0
- {smithy_http-0.3.0 → smithy_http-0.4.0}/src/smithy_http/aio/auth/__init__.py +0 -0
- {smithy_http-0.3.0 → smithy_http-0.4.0}/src/smithy_http/aio/auth/apikey.py +0 -0
- {smithy_http-0.3.0 → smithy_http-0.4.0}/src/smithy_http/aio/identity/__init__.py +0 -0
- {smithy_http-0.3.0 → smithy_http-0.4.0}/src/smithy_http/aio/identity/apikey.py +0 -0
- {smithy_http-0.3.0 → smithy_http-0.4.0}/src/smithy_http/aio/interfaces/__init__.py +0 -0
- {smithy_http-0.3.0 → smithy_http-0.4.0}/src/smithy_http/aio/protocols.py +0 -0
- {smithy_http-0.3.0 → smithy_http-0.4.0}/src/smithy_http/aio/restjson.py +0 -0
- {smithy_http-0.3.0 → smithy_http-0.4.0}/src/smithy_http/bindings.py +0 -0
- {smithy_http-0.3.0 → smithy_http-0.4.0}/src/smithy_http/deserializers.py +0 -0
- {smithy_http-0.3.0 → smithy_http-0.4.0}/src/smithy_http/endpoints.py +0 -0
- {smithy_http-0.3.0 → smithy_http-0.4.0}/src/smithy_http/exceptions.py +0 -0
- {smithy_http-0.3.0 → smithy_http-0.4.0}/src/smithy_http/interceptors/__init__.py +0 -0
- {smithy_http-0.3.0 → smithy_http-0.4.0}/src/smithy_http/interceptors/user_agent.py +0 -0
- {smithy_http-0.3.0 → smithy_http-0.4.0}/src/smithy_http/plugins/__init__.py +0 -0
- {smithy_http-0.3.0 → smithy_http-0.4.0}/src/smithy_http/py.typed +0 -0
- {smithy_http-0.3.0 → smithy_http-0.4.0}/src/smithy_http/restjson.py +0 -0
- {smithy_http-0.3.0 → smithy_http-0.4.0}/src/smithy_http/testing/__init__.py +0 -0
- {smithy_http-0.3.0 → smithy_http-0.4.0}/src/smithy_http/testing/mockhttp.py +0 -0
- {smithy_http-0.3.0 → smithy_http-0.4.0}/src/smithy_http/testing/utils.py +0 -0
- {smithy_http-0.3.0 → smithy_http-0.4.0}/src/smithy_http/user_agent.py +0 -0
- {smithy_http-0.3.0 → smithy_http-0.4.0}/src/smithy_http/utils.py +0 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"changes": [
|
|
3
|
+
{
|
|
4
|
+
"type": "bugfix",
|
|
5
|
+
"description": "Fixed empty error messaging for CRT-based timeout errors."
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
"type": "dependency",
|
|
9
|
+
"description": "Removed strict pinning on `smithy-core` in favor of client managed versions."
|
|
10
|
+
}
|
|
11
|
+
]
|
|
12
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"changes": [
|
|
3
|
+
{
|
|
4
|
+
"type": "breaking",
|
|
5
|
+
"description": "Replace `FieldPosition` enum values with string literals for `Field.kind`. Use \"header\" and \"trailer\" instead of `FieldPosition.HEADER` and `FieldPosition.TRAILER`."
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
"type": "dependency",
|
|
9
|
+
"description": "Upgrade CRT to 0.32.0 to fix bug where HTTP2 exceptions could hang indefinitely"
|
|
10
|
+
}
|
|
11
|
+
]
|
|
12
|
+
}
|
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## v0.4.0
|
|
4
|
+
|
|
5
|
+
### Breaking Changes
|
|
6
|
+
* Replace `FieldPosition` enum values with string literals for `Field.kind`. Use "header" and "trailer" instead of `FieldPosition.HEADER` and `FieldPosition.TRAILER`.
|
|
7
|
+
|
|
8
|
+
### Dependencies
|
|
9
|
+
* Upgrade CRT to 0.32.0 to fix bug where HTTP2 exceptions could hang indefinitely
|
|
10
|
+
|
|
11
|
+
## v0.3.1
|
|
12
|
+
|
|
13
|
+
### Bug fixes
|
|
14
|
+
* Fixed empty error messaging for CRT-based timeout errors.
|
|
15
|
+
|
|
16
|
+
### Dependencies
|
|
17
|
+
* Removed strict pinning on `smithy-core` in favor of client managed versions.
|
|
18
|
+
|
|
3
19
|
## v0.3.0
|
|
4
20
|
|
|
5
21
|
### Features
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: smithy-http
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: HTTP components for Smithy tooling.
|
|
5
5
|
Project-URL: Changelog, https://github.com/smithy-lang/smithy-python/blob/develop/packages/smithy-http/CHANGELOG.md
|
|
6
6
|
Project-URL: Code, https://github.com/smithy-lang/smithy-python/blob/develop/packages/smithy-http/
|
|
@@ -24,12 +24,12 @@ Classifier: Programming Language :: Python :: 3.14
|
|
|
24
24
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
25
25
|
Classifier: Topic :: Software Development :: Libraries
|
|
26
26
|
Requires-Python: >=3.12
|
|
27
|
-
Requires-Dist: smithy-core
|
|
27
|
+
Requires-Dist: smithy-core
|
|
28
28
|
Provides-Extra: aiohttp
|
|
29
29
|
Requires-Dist: aiohttp<4.0,>=3.11.12; extra == 'aiohttp'
|
|
30
30
|
Requires-Dist: yarl; extra == 'aiohttp'
|
|
31
31
|
Provides-Extra: awscrt
|
|
32
|
-
Requires-Dist: awscrt~=0.
|
|
32
|
+
Requires-Dist: awscrt~=0.32.0; extra == 'awscrt'
|
|
33
33
|
Description-Content-Type: text/markdown
|
|
34
34
|
|
|
35
35
|
# smithy-http
|
|
@@ -26,7 +26,7 @@ classifiers = [
|
|
|
26
26
|
"Topic :: Software Development :: Libraries"
|
|
27
27
|
]
|
|
28
28
|
dependencies = [
|
|
29
|
-
"smithy-core
|
|
29
|
+
"smithy-core",
|
|
30
30
|
]
|
|
31
31
|
|
|
32
32
|
[project.urls]
|
|
@@ -36,7 +36,7 @@ dependencies = [
|
|
|
36
36
|
|
|
37
37
|
[project.optional-dependencies]
|
|
38
38
|
awscrt = [
|
|
39
|
-
"awscrt~=0.
|
|
39
|
+
"awscrt~=0.32.0",
|
|
40
40
|
]
|
|
41
41
|
aiohttp = [
|
|
42
42
|
"aiohttp>=3.11.12, <4.0",
|
|
@@ -2,11 +2,14 @@
|
|
|
2
2
|
# SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
from collections import Counter, OrderedDict
|
|
4
4
|
from collections.abc import Iterable, Iterator
|
|
5
|
+
from typing import get_args
|
|
5
6
|
|
|
6
7
|
from . import interfaces
|
|
7
8
|
from .interfaces import FieldPosition
|
|
8
9
|
|
|
9
|
-
__version__ = "0.
|
|
10
|
+
__version__ = "0.4.0"
|
|
11
|
+
|
|
12
|
+
_VALID_FIELD_POSITIONS = frozenset(get_args(FieldPosition))
|
|
10
13
|
|
|
11
14
|
|
|
12
15
|
class Field(interfaces.Field):
|
|
@@ -24,10 +27,12 @@ class Field(interfaces.Field):
|
|
|
24
27
|
*,
|
|
25
28
|
name: str,
|
|
26
29
|
values: Iterable[str] | None = None,
|
|
27
|
-
kind: FieldPosition =
|
|
30
|
+
kind: FieldPosition = "header",
|
|
28
31
|
):
|
|
29
32
|
self.name = name
|
|
30
33
|
self.values: list[str] = list(values) if values is not None else []
|
|
34
|
+
if kind not in _VALID_FIELD_POSITIONS:
|
|
35
|
+
raise ValueError(f"Unknown field kind: {kind!r}")
|
|
31
36
|
self.kind = kind
|
|
32
37
|
|
|
33
38
|
def add(self, value: str) -> None:
|
|
@@ -79,7 +84,7 @@ class Field(interfaces.Field):
|
|
|
79
84
|
return False
|
|
80
85
|
return (
|
|
81
86
|
self.name == other.name
|
|
82
|
-
and self.kind
|
|
87
|
+
and self.kind == other.kind
|
|
83
88
|
and self.values == other.values
|
|
84
89
|
)
|
|
85
90
|
|
|
@@ -153,7 +158,7 @@ class Fields(interfaces.Fields):
|
|
|
153
158
|
|
|
154
159
|
Used to grab all headers or all trailers.
|
|
155
160
|
"""
|
|
156
|
-
return [entry for entry in self.entries.values() if entry.kind
|
|
161
|
+
return [entry for entry in self.entries.values() if entry.kind == kind]
|
|
157
162
|
|
|
158
163
|
def extend(self, other: interfaces.Fields) -> None:
|
|
159
164
|
"""Merges ``entries`` of ``other`` into the current ``entries``.
|
|
@@ -225,8 +230,6 @@ def tuples_to_fields(
|
|
|
225
230
|
try:
|
|
226
231
|
fields[name].add(value)
|
|
227
232
|
except KeyError:
|
|
228
|
-
fields[name] = Field(
|
|
229
|
-
name=name, values=[value], kind=kind or FieldPosition.HEADER
|
|
230
|
-
)
|
|
233
|
+
fields[name] = Field(name=name, values=[value], kind=kind or "header")
|
|
231
234
|
|
|
232
235
|
return fields
|
|
@@ -28,7 +28,6 @@ from smithy_core.interfaces import URI
|
|
|
28
28
|
|
|
29
29
|
from .. import Field, Fields
|
|
30
30
|
from ..interfaces import (
|
|
31
|
-
FieldPosition,
|
|
32
31
|
HTTPClientConfiguration,
|
|
33
32
|
HTTPRequestConfiguration,
|
|
34
33
|
)
|
|
@@ -125,7 +124,7 @@ class AIOHTTPClient(HTTPClient):
|
|
|
125
124
|
headers[header_name] = Field(
|
|
126
125
|
name=header_name,
|
|
127
126
|
values=[header_val],
|
|
128
|
-
kind=
|
|
127
|
+
kind="header",
|
|
129
128
|
)
|
|
130
129
|
|
|
131
130
|
return HTTPResponse(
|
|
@@ -41,7 +41,6 @@ from smithy_core.exceptions import MissingDependencyError
|
|
|
41
41
|
from .. import Field, Fields
|
|
42
42
|
from .. import interfaces as http_interfaces
|
|
43
43
|
from ..exceptions import SmithyHTTPError
|
|
44
|
-
from ..interfaces import FieldPosition
|
|
45
44
|
from . import interfaces as http_aio_interfaces
|
|
46
45
|
|
|
47
46
|
# Default buffer size for reading from streams (8 KB)
|
|
@@ -187,7 +186,7 @@ class AWSCRTHTTPClient(http_aio_interfaces.HTTPClient):
|
|
|
187
186
|
return await self._await_response(crt_stream)
|
|
188
187
|
except AwsCrtError as e:
|
|
189
188
|
if e.name in self._TIMEOUT_ERROR_NAMES:
|
|
190
|
-
raise _CRTTimeoutError() from e
|
|
189
|
+
raise _CRTTimeoutError(f"CRT {e.name}: {e.message}") from e
|
|
191
190
|
raise
|
|
192
191
|
|
|
193
192
|
async def _await_response(
|
|
@@ -203,7 +202,7 @@ class AWSCRTHTTPClient(http_aio_interfaces.HTTPClient):
|
|
|
203
202
|
fields[header_name] = Field(
|
|
204
203
|
name=header_name,
|
|
205
204
|
values=[header_val],
|
|
206
|
-
kind=
|
|
205
|
+
kind="header",
|
|
207
206
|
)
|
|
208
207
|
return AWSCRTHTTPResponse(
|
|
209
208
|
status=status_code,
|
|
@@ -294,8 +293,7 @@ class AWSCRTHTTPClient(http_aio_interfaces.HTTPClient):
|
|
|
294
293
|
request.fields.set_field(Field(name="accept", values=["*/*"]))
|
|
295
294
|
|
|
296
295
|
for fld in request.fields.entries.values():
|
|
297
|
-
|
|
298
|
-
if fld.kind.value != FieldPosition.HEADER.value:
|
|
296
|
+
if fld.kind != "header":
|
|
299
297
|
continue
|
|
300
298
|
for val in fld.values:
|
|
301
299
|
headers_list.append((fld.name, val))
|
|
@@ -2,29 +2,18 @@
|
|
|
2
2
|
# SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
from collections.abc import Iterator
|
|
4
4
|
from dataclasses import dataclass
|
|
5
|
-
from
|
|
6
|
-
from typing import Protocol
|
|
5
|
+
from typing import Literal, Protocol
|
|
7
6
|
|
|
7
|
+
FieldPosition = Literal["header", "trailer"]
|
|
8
|
+
"""The type of a field.
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
"""The type of a field.
|
|
10
|
+
Defines its placement in a request or response.
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
HEADER = 0
|
|
16
|
-
"""Header field.
|
|
17
|
-
|
|
18
|
-
In HTTP this is a header as defined in RFC 9110 Section 6.3. Implementations of
|
|
19
|
-
other protocols may use this FieldPosition for similar types of metadata.
|
|
20
|
-
"""
|
|
21
|
-
|
|
22
|
-
TRAILER = 1
|
|
23
|
-
"""Trailer field.
|
|
12
|
+
header: Header field. In HTTP this is a header as defined in RFC 9110 Section 6.3.
|
|
13
|
+
trailer: Trailer field. In HTTP this is a trailer as defined in RFC 9110 Section 6.5.
|
|
24
14
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"""
|
|
15
|
+
Implementations of other protocols may use this FieldPosition for similar types of metadata.
|
|
16
|
+
"""
|
|
28
17
|
|
|
29
18
|
|
|
30
19
|
class Field(Protocol):
|
|
@@ -40,7 +29,7 @@ class Field(Protocol):
|
|
|
40
29
|
|
|
41
30
|
name: str
|
|
42
31
|
values: list[str]
|
|
43
|
-
kind: FieldPosition =
|
|
32
|
+
kind: FieldPosition = "header"
|
|
44
33
|
|
|
45
34
|
def add(self, value: str) -> None:
|
|
46
35
|
"""Append a value to a field."""
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
from asyncio import iscoroutinefunction
|
|
4
3
|
from base64 import b64encode
|
|
5
4
|
from collections.abc import Callable, Iterator, Sized
|
|
6
5
|
from contextlib import contextmanager
|
|
7
6
|
from datetime import datetime
|
|
8
7
|
from decimal import Decimal
|
|
8
|
+
from inspect import iscoroutinefunction
|
|
9
9
|
from io import BytesIO
|
|
10
10
|
from typing import TYPE_CHECKING
|
|
11
11
|
from urllib.parse import quote as urlquote
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|