awslabs / aws-sdk-swift

Apache License 2.0
379 stars 74 forks source link

Configure ALPN based on the values provided by the service's protocol #948

Open epau opened 1 year ago

epau commented 1 year ago

Describe the feature

AWS protocols define properties (http and eventStreamHttp) that contain the priority ordered list of supported HTTP protocol versions, The SDK must configure the http client of the service to use the values defined by the service's protocol.

Consult with smithy folks to understand if/how this should be exposed via SRA. Currently a http client just defines a single function send(request: HTTPRequest). How does configuring the ALPN list and other low-level connection settings fit into this? (such as configuring ALPN and minimum TLS version etc)

For example, below are the rules for the AWS restJson1 protocol:

Each entry in http and eventStreamHttp SHOULD be a valid Application-Layer Protocol Negotiation (ALPN) Protocol ID (for example, http/1.1, h2, etc). Clients SHOULD pick the first protocol in the list they understand when connecting to a service. A client SHOULD assume that a service supports http/1.1 when no http or eventStreamHttp values are provided.

Use Case

N/A

Proposed Solution

No response

Other Information

No response

Acknowledgements

epau commented 1 year ago

Related: https://github.com/awslabs/aws-sdk-swift/issues/702

AndrewFossAWS commented 4 months ago

The aws-swift-sdk uses Apple's URLSession for ios platforms and CRTEngline for linux platform. Hence the supported protocol versions (and their priorities) are dictated by these clients, and not by Smithy protocol traits.

For URLSession, it supports HTTP/1.1, HTTP/2, and HTTP/3 protocols. For CRTEngine, it supports HTTP/1.1 and HTTP/2 only.

The only thing we can add/include is to validate at least one of the protocols specified in the Smithy protocol trait is also supported by the above http clients.

jbelkins commented 3 months ago

Clients are negotiating HTTP version with the server directly, and should throw an appropriate error when an agreement can't be made.