smithy-http
Field
¶
Bases: Field
A name-value pair representing a single field in an HTTP Request or Response.
The kind will dictate metadata placement within an HTTP message.
All field names are case insensitive and case-variance must be treated as equivalent. Names may be normalized but should be preserved for accuracy during transmission.
Source code in packages/smithy-http/src/smithy_http/__init__.py
__eq__(other)
¶
Name, values, and kind must match.
Values order must match.
Source code in packages/smithy-http/src/smithy_http/__init__.py
add(value)
¶
as_string(delimiter=',')
¶
Get delimited string of all values. A comma is used by default.
If the Field
has zero values, the empty string is returned. If the Field
has exactly one value, the value is returned unmodified.
For Field
s with more than one value, the values are joined by a comma and a
space. For such multi-valued Field
s, any values that already contain
commas or double quotes will be surrounded by double quotes. Within any values
that get quoted, pre-existing double quotes and backslashes are escaped with a
backslash.
Source code in packages/smithy-http/src/smithy_http/__init__.py
as_tuples()
¶
Get list of name
, value
tuples where each tuple represents one
value.
remove(value)
¶
Fields
¶
Bases: Fields
Source code in packages/smithy-http/src/smithy_http/__init__.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
|
__delitem__(name)
¶
__eq__(other)
¶
Encoding must match.
Entries must match in values and order.
Source code in packages/smithy-http/src/smithy_http/__init__.py
__getitem__(name)
¶
__init__(initial=None, *, encoding='utf-8')
¶
Collection of header and trailer entries mapped by name.
:param initial: Initial list of Field
objects. Field
s can also be added
and later removed.
:param encoding: The string encoding to be used when converting the Field
name and value from str
to bytes
for transmission.
Source code in packages/smithy-http/src/smithy_http/__init__.py
__setitem__(name, field)
¶
Set or override entry for a Field name.
Source code in packages/smithy-http/src/smithy_http/__init__.py
extend(other)
¶
Merges entries
of other
into the current entries
.
For every Field
in the entries
of other
: If the normalized name
already exists in the current entries
, the values from other
are
appended. Otherwise, the Field
is added to the list of entries
.
Source code in packages/smithy-http/src/smithy_http/__init__.py
get_by_type(kind)
¶
Helper function for retrieving specific types of fields.
Used to grab all headers or all trailers.
Source code in packages/smithy-http/src/smithy_http/__init__.py
set_field(field)
¶
Alias for setitem to utilize the field.name for the entry key.
quote_and_escape_field_value(value)
¶
Escapes and quotes a single :class:Field
value if necessary.
See :func:Field.as_string
for quoting and escaping logic.
Source code in packages/smithy-http/src/smithy_http/__init__.py
tuples_to_fields(tuples, *, kind=None)
¶
Convert name
, value
tuples to Fields
object. Each tuple represents
one Field value.
:param kind: The Field kind to define for all tuples.
Source code in packages/smithy-http/src/smithy_http/__init__.py
aio
¶
HTTPRequest
dataclass
¶
Bases: HTTPRequest
HTTP primitives for an Exchange to construct a version agnostic HTTP message.
Source code in packages/smithy-http/src/smithy_http/aio/__init__.py
HTTPResponse
dataclass
¶
Basic implementation of :py:class:.interfaces.HTTPResponse
.
Implementations of :py:class:.interfaces.HTTPClient
may return instances of this
class or of custom response implementations.
Source code in packages/smithy-http/src/smithy_http/aio/__init__.py
body = field(repr=False, default=b'')
class-attribute
instance-attribute
¶
The response payload as iterable of chunks of bytes.
fields
instance-attribute
¶
HTTP header and trailer fields.
reason = None
class-attribute
instance-attribute
¶
Optional string provided by the server explaining the status.
status
instance-attribute
¶
The 3 digit response status code (1xx, 2xx, 3xx, 4xx, 5xx).
consume_body()
¶
consume_body_async()
async
¶
aiohttp
¶
AIOHTTPClient
¶
Bases: HTTPClient
Implementation of :py:class:.interfaces.HTTPClient
using aiohttp.
Source code in packages/smithy-http/src/smithy_http/aio/aiohttp.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
|
__init__(*, client_config=None, _session=None)
¶
:param client_config: Configuration that applies to all requests made with this client.
Source code in packages/smithy-http/src/smithy_http/aio/aiohttp.py
send(request, *, request_config=None)
async
¶
Send HTTP request using aiohttp client.
:param request: The request including destination URI, fields, payload. :param request_config: Configuration specific to this request.
Source code in packages/smithy-http/src/smithy_http/aio/aiohttp.py
auth
¶
apikey
¶
API_KEY_RESOLVER_CONFIG = PropertyKey(key='config', value_type=APIKeyResolverConfig)
module-attribute
¶
A context property bearing an API key config.
APIKeyAuthScheme
¶
Bases: AuthScheme[HTTPRequest, APIKeyIdentity, APIKeyIdentityProperties, Any]
An auth scheme containing necessary data and tools for api key auth.
Source code in packages/smithy-http/src/smithy_http/aio/auth/apikey.py
APIKeyResolverConfig
¶
Bases: Protocol
A config bearing API key properties.
Source code in packages/smithy-http/src/smithy_http/aio/auth/apikey.py
APIKeySigner
¶
Bases: Signer[HTTPRequest, APIKeyIdentity, Any]
A signer that signs http requests with an api key.
Source code in packages/smithy-http/src/smithy_http/aio/auth/apikey.py
crt
¶
AWSCRTHTTPClient
¶
Bases: HTTPClient
Source code in packages/smithy-http/src/smithy_http/aio/crt.py
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 |
|
__init__(eventloop=None, client_config=None)
¶
:param client_config: Configuration that applies to all requests made with this client.
Source code in packages/smithy-http/src/smithy_http/aio/crt.py
send(request, *, request_config=None)
async
¶
Send HTTP request using awscrt client.
:param request: The request including destination URI, fields, payload. :param request_config: Configuration specific to this request.
Source code in packages/smithy-http/src/smithy_http/aio/crt.py
AWSCRTHTTPResponse
¶
Bases: HTTPResponse
Source code in packages/smithy-http/src/smithy_http/aio/crt.py
reason
property
¶
Optional string provided by the server explaining the status.
BufferableByteStream
¶
Bases: BufferedIOBase
A non-blocking bytes buffer.
Source code in packages/smithy-http/src/smithy_http/aio/crt.py
413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 |
|
end_stream()
¶
End the stream, letting any remaining chunks be read before it is closed.
identity
¶
apikey
¶
APIKeyIdentity
dataclass
¶
APIKeyIdentityResolver
¶
Bases: IdentityResolver[APIKeyIdentity, APIKeyIdentityProperties]
Loads the API key identity from the configuration.
Source code in packages/smithy-http/src/smithy_http/aio/identity/apikey.py
interfaces
¶
HTTPClient
¶
Bases: ClientTransport[HTTPRequest, HTTPResponse]
, Protocol
An asynchronous HTTP client interface.
Source code in packages/smithy-http/src/smithy_http/aio/interfaces/__init__.py
__init__(*, client_config)
¶
:param client_config: Configuration that applies to all requests made with this client.
send(request, *, request_config=None)
async
¶
Send HTTP request over the wire and return the response.
:param request: The request including destination URI, fields, payload. :param request_config: Configuration specific to this request.
Source code in packages/smithy-http/src/smithy_http/aio/interfaces/__init__.py
HTTPErrorIdentifier
¶
A class that uses HTTP response metadata to identify errors.
The body of the response SHOULD NOT be touched by this. The payload codec will be used instead to check for an ID in the body.
Source code in packages/smithy-http/src/smithy_http/aio/interfaces/__init__.py
identify(*, operation, response)
¶
Idenitfy the ShapeID of an error from an HTTP response.
HTTPRequest
¶
Bases: Request
, Protocol
HTTP primitive for an Exchange to construct a version agnostic HTTP message.
:param destination: The URI where the request should be sent to.
:param method: The HTTP method of the request, for example "GET".
:param fields: Fields
object containing HTTP headers and trailers.
:param body: A streamable collection of bytes.
Source code in packages/smithy-http/src/smithy_http/aio/interfaces/__init__.py
HTTPResponse
¶
Bases: Response
, Protocol
HTTP primitives returned from an Exchange, used to construct a client response.
Source code in packages/smithy-http/src/smithy_http/aio/interfaces/__init__.py
protocols
¶
HttpBindingClientProtocol
¶
Bases: HttpClientProtocol
An HTTP-based protocol that uses HTTP binding traits.
Source code in packages/smithy-http/src/smithy_http/aio/protocols.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
|
HttpClientProtocol
¶
Bases: ClientProtocol[HTTPRequest, HTTPResponse]
An HTTP-based protocol.
Source code in packages/smithy-http/src/smithy_http/aio/protocols.py
restjson
¶
parse_rest_json_error_info(http_response, check_body=True)
async
¶
Parses generic RestJson error info from an HTTP response.
:param http_response: The HTTP response to parse. :param check_body: Whether to check the body for the code / message. :returns: The parsed error information.
Source code in packages/smithy-http/src/smithy_http/aio/restjson.py
bindings
¶
Binding
¶
Bases: Enum
HTTP binding locations.
Source code in packages/smithy-http/src/smithy_http/bindings.py
BODY = 3
class-attribute
instance-attribute
¶
Indicates the member is a property in the HTTP payload structure.
HEADER = 0
class-attribute
instance-attribute
¶
Indicates the member is bound to a header.
HOST = 8
class-attribute
instance-attribute
¶
Indicates the member is bound to a prefix to the host AND to the body.
LABEL = 4
class-attribute
instance-attribute
¶
Indicates the member is bound to a path segment in the URI.
PAYLOAD = 2
class-attribute
instance-attribute
¶
Indicates the member is bound to the entire HTTP payload.
PREFIX_HEADERS = 6
class-attribute
instance-attribute
¶
Indicates the member is bound to multiple headers with a shared prefix.
QUERY = 1
class-attribute
instance-attribute
¶
Indicates the member is bound to a query parameter.
QUERY_PARAMS = 7
class-attribute
instance-attribute
¶
Indicates the member is bound to the query string as multiple key-value pairs.
STATUS = 5
class-attribute
instance-attribute
¶
Indicates the member is bound to the response status code.
RequestBindingMatcher
dataclass
¶
Bases: _BindingMatcher
Matches structure members to HTTP request binding locations.
Source code in packages/smithy-http/src/smithy_http/bindings.py
__init__(struct)
¶
Initialize a RequestBindingMatcher.
:param struct: The structure to examine for HTTP bindings.
ResponseBindingMatcher
dataclass
¶
Bases: _BindingMatcher
Matches structure members to HTTP response binding locations.
Source code in packages/smithy-http/src/smithy_http/bindings.py
__init__(struct)
¶
Initialize a ResponseBindingMatcher.
:param struct: The structure to examine for HTTP bindings.
deserializers
¶
HTTPHeaderDeserializer
¶
Bases: SpecificShapeDeserializer
Binds HTTP header values to a deserializable shape.
For headers with list values, see :py:class:HTTPHeaderListDeserializer
.
Source code in packages/smithy-http/src/smithy_http/deserializers.py
__init__(value)
¶
Initialize an HTTPHeaderDeserializer.
:param value: The string value of the header.
HTTPHeaderListDeserializer
¶
Bases: SpecificShapeDeserializer
Binds HTTP header lists to a deserializable shape.
Source code in packages/smithy-http/src/smithy_http/deserializers.py
__init__(field)
¶
Initialize an HTTPHeaderListDeserializer.
:param field: The field to deserialize.
HTTPHeaderMapDeserializer
¶
Bases: SpecificShapeDeserializer
Binds HTTP header maps to a deserializable shape.
Source code in packages/smithy-http/src/smithy_http/deserializers.py
__init__(fields, prefix='')
¶
Initialize an HTTPHeaderMapDeserializer.
:param fields: The collection of headers to search for map values. :param prefix: An optional prefix to limit which headers are pulled in to the map. By default, all headers are pulled in, including headers that are bound to other properties on the shape.
Source code in packages/smithy-http/src/smithy_http/deserializers.py
HTTPResponseCodeDeserializer
¶
Bases: SpecificShapeDeserializer
Binds HTTP response codes to a deserializeable shape.
Source code in packages/smithy-http/src/smithy_http/deserializers.py
__init__(response_code)
¶
Initialize an HTTPResponseCodeDeserializer.
:param response_code: The response code to bind.
HTTPResponseDeserializer
¶
Bases: SpecificShapeDeserializer
Binds :py:class:HTTPResponse
properties to a DeserializableShape.
Source code in packages/smithy-http/src/smithy_http/deserializers.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
|
__init__(*, payload_codec, response, http_trait=None, body=None)
¶
Initialize an HTTPResponseDeserializer.
:param payload_codec: The Codec to use to deserialize the payload, if present. :param response: The HTTP response to read from. :param http_trait: The HTTP trait of the operation being handled. :param body: The HTTP response body in a synchronously readable form. This is necessary for async response bodies when there is no streaming member.
Source code in packages/smithy-http/src/smithy_http/deserializers.py
RawPayloadDeserializer
¶
Bases: SpecificShapeDeserializer
Binds an HTTP payload to a deserializeable shape.
Source code in packages/smithy-http/src/smithy_http/deserializers.py
__init__(payload)
¶
Initialize a RawPayloadDeserializer.
:param payload: The payload to bind. If the member that is bound to the payload is a string or blob, it MUST NOT be an async stream. Async streams MUST be buffered into a synchronous stream ahead of time.
Source code in packages/smithy-http/src/smithy_http/deserializers.py
endpoints
¶
HEADERS = PropertyKey(key='headers', value_type=(interfaces.Fields))
module-attribute
¶
An Endpoint property indicating the given fields MUST be added to the request.
HTTPEndpoint
dataclass
¶
Bases: Endpoint
A resolved endpoint with optional HTTP headers.
Source code in packages/smithy-http/src/smithy_http/endpoints.py
exceptions
¶
SmithyHTTPError
¶
Bases: SmithyError
Base exception type for all exceptions raised in HTTP clients.
interceptors
¶
user_agent
¶
UserAgentInterceptor
¶
Bases: Interceptor[Any, Any, HTTPRequest, None]
Adds interceptors that initialize UserAgent in the context and add the user-agent header.
Source code in packages/smithy-http/src/smithy_http/interceptors/user_agent.py
interfaces
¶
Field
¶
Bases: Protocol
A name-value pair representing a single field in a request or response.
The kind will dictate metadata placement within an the message, for example as header or trailer field in a HTTP request as defined in RFC 9110 Section 5.
All field names are case insensitive and case-variance must be treated as equivalent. Names may be normalized but should be preserved for accuracy during transmission.
Source code in packages/smithy-http/src/smithy_http/interfaces/__init__.py
FieldPosition
¶
Bases: Enum
The type of a field.
Defines its placement in a request or response.
Source code in packages/smithy-http/src/smithy_http/interfaces/__init__.py
HEADER = 0
class-attribute
instance-attribute
¶
Header field.
In HTTP this is a header as defined in RFC 9110 Section 6.3. Implementations of other protocols may use this FieldPosition for similar types of metadata.
TRAILER = 1
class-attribute
instance-attribute
¶
Trailer field.
In HTTP this is a trailer as defined in RFC 9110 Section 6.5. Implementations of other protocols may use this FieldPosition for similar types of metadata.
Fields
¶
Bases: Protocol
Protocol agnostic mapping of key-value pair request metadata, such as HTTP fields.
Source code in packages/smithy-http/src/smithy_http/interfaces/__init__.py
__contains__(key)
¶
__delitem__(name)
¶
__getitem__(name)
¶
__iter__()
¶
__len__()
¶
__setitem__(name, field)
¶
extend(other)
¶
Merges entries
of other
into the current entries
.
For every Field
in the entries
of other
: If the normalized name
already exists in the current entries
, the values from other
are
appended. Otherwise, the Field
is added to the list of entries
.
Source code in packages/smithy-http/src/smithy_http/interfaces/__init__.py
get_by_type(kind)
¶
Helper function for retrieving specific types of fields.
Used to grab all headers or all trailers.
HTTPClientConfiguration
dataclass
¶
Client-level HTTP configuration.
:param force_http_2: Whether to require HTTP/2.
Source code in packages/smithy-http/src/smithy_http/interfaces/__init__.py
HTTPRequestConfiguration
dataclass
¶
Request-level HTTP configuration.
:param read_timeout: How long, in seconds, the client will attempt to read the first byte over an established, open connection before timing out.
Source code in packages/smithy-http/src/smithy_http/interfaces/__init__.py
restjson
¶
RestJsonErrorInfo
¶
Bases: NamedTuple
Generic error information from a RestJson protocol error.
Source code in packages/smithy-http/src/smithy_http/restjson.py
code
instance-attribute
¶
The error code.
json_body = None
class-attribute
instance-attribute
¶
The HTTP response body parsed as JSON.
message
instance-attribute
¶
The generic error message.
A modeled error may have the error bound somewhere else. This is based off of checking the most common locations and is intended for use with excpetions that either didn't model the message or which are unknown.
serializers
¶
CapturingSerializer
¶
Bases: SpecificShapeSerializer
Directly passes along a string through a serializer.
Source code in packages/smithy-http/src/smithy_http/serializers.py
result = None
instance-attribute
¶
The captured string.
This will only be set after the serializer has been used.
HTTPHeaderMapSerializer
¶
Bases: MapSerializer
Binds a mapping property of a serializeable shape to multiple HTTP headers.
Source code in packages/smithy-http/src/smithy_http/serializers.py
__init__(prefix, headers)
¶
Initialize an HTTPHeaderMapSerializer.
:param prefix: The prefix to prepend to each of the map keys. :param headers: The list of header tuples to append to.
Source code in packages/smithy-http/src/smithy_http/serializers.py
HTTPHeaderSerializer
¶
Bases: SpecificShapeSerializer
Binds properties of a serializable shape to HTTP headers.
Source code in packages/smithy-http/src/smithy_http/serializers.py
445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 |
|
headers = headers if headers is not None else []
instance-attribute
¶
A list of serialized headers.
This should only be accessed after serialization.
__init__(key=None, headers=None)
¶
Initialize an HTTPHeaderSerializer.
:param key: An optional key to specifically write. If not set, the
:py:class:HTTPHeaderTrait
will be checked instead. Required when
collecting list entries.
:param headers: An optional list of header tuples to append to. If not
set, one will be created. Values appended will not be escaped.
Source code in packages/smithy-http/src/smithy_http/serializers.py
HTTPPathSerializer
¶
Bases: SpecificShapeSerializer
Binds properties of a serializable shape to the HTTP URI path.
Source code in packages/smithy-http/src/smithy_http/serializers.py
path
property
¶
Get the formatted path.
This must not be accessed before serialization is complete, otherwise an exception will be raised.
__init__(path_pattern)
¶
Initialize an HTTPPathSerializer.
:param path_pattern: The pattern to bind properties to. This is also used to detect greedy labels, which have different escaping requirements.
Source code in packages/smithy-http/src/smithy_http/serializers.py
HTTPQueryMapSerializer
¶
Bases: MapSerializer
Binds properties of a serializable shape to a map of HTTP query params.
Source code in packages/smithy-http/src/smithy_http/serializers.py
__init__(query_params)
¶
Initialize an HTTPQueryMapSerializer.
:param query_params: The list of query param tuples to append to.
HTTPQueryMapValueSerializer
¶
Bases: SpecificShapeSerializer
Source code in packages/smithy-http/src/smithy_http/serializers.py
__init__(key, query_params)
¶
Initialize an HTTPQueryMapValueSerializer.
:param key: The key of the query parameter. :param query_params: The list of query param tuples to append to.
Source code in packages/smithy-http/src/smithy_http/serializers.py
HTTPQuerySerializer
¶
Bases: SpecificShapeSerializer
Binds properties of a serializable shape to HTTP URI query params.
Source code in packages/smithy-http/src/smithy_http/serializers.py
__init__(key=None, params=None)
¶
Initialize an HTTPQuerySerializer.
:param key: An optional key to specifically write. If not set, the
:py:class:HTTPQueryTrait
will be checked instead. Required when
collecting list or map entries.
:param headers: An optional list of header tuples to append to. If not
set, one will be created.
Source code in packages/smithy-http/src/smithy_http/serializers.py
HTTPRequestBindingSerializer
¶
Bases: InterceptingSerializer
Delegates HTTP request bindings to binding-location-specific serializers.
Source code in packages/smithy-http/src/smithy_http/serializers.py
__init__(payload_serializer, path_pattern, host_prefix_pattern, binding_matcher)
¶
Initialize an HTTPRequestBindingSerializer.
:param payload_serializer: The :py:class:ShapeSerializer
to use to serialize
the payload, if necessary.
:param path_pattern: The pattern used to construct the path.
:host_prefix_pattern: The pattern used to construct the host prefix.
Source code in packages/smithy-http/src/smithy_http/serializers.py
HTTPRequestSerializer
¶
Bases: SpecificShapeSerializer
Binds a serializable shape to an HTTP request.
The resultant HTTP request is not immediately sendable. In particular, the host of the destination URI is incomplete and MUST be suffixed before sending.
Source code in packages/smithy-http/src/smithy_http/serializers.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
|
__init__(payload_codec, http_trait, endpoint_trait=None, omit_empty_payload=True)
¶
Initialize an HTTPRequestSerializer.
:param payload_codec: The codec to use to serialize the HTTP payload, if one is present. :param http_trait: The HTTP trait of the operation being handled. :param endpoint_trait: The optional endpoint trait of the operation being handled. :param omit_empty_payload: Whether an empty payload should be omitted.
Source code in packages/smithy-http/src/smithy_http/serializers.py
HTTPResponseBindingSerializer
¶
Bases: InterceptingSerializer
Delegates HTTP response bindings to binding-location-specific serializers.
Source code in packages/smithy-http/src/smithy_http/serializers.py
__init__(payload_serializer, binding_matcher)
¶
Initialize an HTTPResponseBindingSerializer.
:param payload_serializer: The :py:class:ShapeSerializer
to use to serialize
the payload, if necessary.
Source code in packages/smithy-http/src/smithy_http/serializers.py
HTTPResponseCodeSerializer
¶
Bases: SpecificShapeSerializer
Binds properties of a serializable shape to the HTTP response code.
Source code in packages/smithy-http/src/smithy_http/serializers.py
response_code = None
instance-attribute
¶
The bound response code, or None if one hasn't been bound.
HTTPResponseSerializer
¶
Bases: SpecificShapeSerializer
Binds a serializable shape to an HTTP response.
Source code in packages/smithy-http/src/smithy_http/serializers.py
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 |
|
__init__(payload_codec, http_trait, omit_empty_payload=True)
¶
Initialize an HTTPResponseSerializer.
:param payload_codec: The codec to use to serialize the HTTP payload, if one is present. :param http_trait: The HTTP trait of the operation being handled. :param omit_empty_payload: Whether an empty payload should be omitted.
Source code in packages/smithy-http/src/smithy_http/serializers.py
HostPrefixSerializer
¶
Bases: SpecificShapeSerializer
Binds properites of a serializable shape to the HTTP URI host.
These properties are also bound to the payload.
Source code in packages/smithy-http/src/smithy_http/serializers.py
host_prefix
property
¶
The formatted host prefix.
This must not be accessed before serialization is complete, otherwise an exception will be raised.
__init__(payload_serializer, host_prefix_pattern)
¶
Initialize a HostPrefixSerializer.
:param host_prefix_pattern: The pattern to bind properties to. :param payload_serializer: The payload serializer to additionally write properties to.
Source code in packages/smithy-http/src/smithy_http/serializers.py
RawPayloadSerializer
¶
Bases: SpecificShapeSerializer
Binds properties of serializable shape to an HTTP payload.
Source code in packages/smithy-http/src/smithy_http/serializers.py
payload = None
instance-attribute
¶
The serialized payload.
This will only be non-null after serialization.
user_agent
¶
RawStringUserAgentComponent
dataclass
¶
UserAgentComponent interface wrapper around str
.
Use for User-Agent header components that are not constructed from prefix+name+value but instead are provided as strings. No sanitization is performed.
Source code in packages/smithy-http/src/smithy_http/user_agent.py
UserAgentComponent
dataclass
¶
Component of a User-Agent header string in the standard format.
Each component consists of a prefix, a name, and a value. In the string
representation these are combined in the format prefix/name#value
.
This class is considered private and is subject to abrupt breaking changes.
Source code in packages/smithy-http/src/smithy_http/user_agent.py
__str__()
¶
Create string like 'prefix/name#value' from a UserAgentComponent.
Source code in packages/smithy-http/src/smithy_http/user_agent.py
sanitize_user_agent_string_component(raw_str, allow_hash=False)
¶
Replaces all not allowed characters in the string with a dash ("-").
Allowed characters are ASCII alphanumerics and !$%&'*+-.^_`|~
. If
allow_hash
is True
, "#"``" is also allowed.
:type raw_str: str :param raw_str: The input string to be sanitized.
:type allow_hash: bool :param allow_hash: Whether "#" is considered an allowed character.
Source code in packages/smithy-http/src/smithy_http/user_agent.py
utils
¶
join_query_params(params, prefix='')
¶
Join a list of query parameter key-value tuples.
:param params: The list of key-value query parameter tuples. :param prefix: An optional query prefix.
Source code in packages/smithy-http/src/smithy_http/utils.py
split_header(given, handle_unquoted_http_date=False)
¶
Splits a header value into a list of strings.
The format is based on RFC9110's list production found in secion 5.6.1 with the quoted string production found in section 5.6.4. In short:
A list is 1 or more elements surrounded by optional whitespace and separated by
commas. Elements may be quoted with double quotes ("
) to contain leading or
trailing whitespace, commas, or double quotes. Inside the the double quotes, a
value may be escaped with a backslash (\
). Elements that contain no contents
are ignored.
If the list is known to contain unquoted IMF-fixdate formatted timestamps, the
handle_unquoted_http_date
parameter can be set to ensure the list isn't
split on the commas inside the timestamps.
:param given: The header value to split. :param handle_unquoted_http_date: Support splitting IMF-fixdate lists without quotes. Defaults to False. :returns: The header value split on commas.