Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require an Accept header for RPCv2 requests #2417

Merged
merged 1 commit into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions docs/source-2.0/additional-specs/protocols/smithy-rpc-v2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,16 @@ Buffered RPC requests for the ``rpcv2Cbor`` protocol SHOULD include a
``Content-Length`` header. Event streaming requests MUST NOT specify a content
length (instead using ``Transfer-Encoding: chunked`` on HTTP/1.1).

Requests with event stream responses for the ``rpcv2Cbor`` protocol MUST
include an ``Accept`` header set to the value
``application/vnd.amazon.eventstream``. Other forms of content streaming MAY be
added in the future, utilizing different values for ``Accept``.
Requests for the ``rpcv2Cbor`` protocol MUST use the following behavior for
setting an ``Accept`` header:

* For requests with event streaming responses: the value of the ``Accept``
header MUST be ``application/vnd.amazon.eventstream``.
* For requests with all other response types: the value of the ``Accept``
header MUST be ``application/cbor``.

Other forms of content streaming MAY be added in the future, utilizing
different values for ``Accept``.

In summary, the ``rpcv2Cbor`` protocol defines behavior for the following
headers for requests:
Expand All @@ -241,9 +247,9 @@ headers for requests:
- The standard ``Content-Length`` header defined by :rfc:`9110#section-8.6`.
For event streaming requests, this MUST NOT be set.
* - ``Accept``
- Conditional
- For requests with event streaming responses, this is
``application/vnd.amazon.eventstream``.
- Required
- The value of ``application/cbor``. For requests with event streaming
responses, this is ``application/vnd.amazon.eventstream``.


~~~~~~~~~
Expand Down
21 changes: 14 additions & 7 deletions smithy-protocol-tests/model/rpcv2Cbor/cbor-lists.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ apply RpcV2CborLists @httpRequestTests([
bodyMediaType: "application/cbor",
headers: {
"smithy-protocol": "rpc-v2-cbor",
"Content-Type": "application/cbor"
"Content-Type": "application/cbor",
"Accept": "application/cbor"
},
requireHeaders: [
"Content-Length"
Expand Down Expand Up @@ -116,7 +117,8 @@ apply RpcV2CborLists @httpRequestTests([
bodyMediaType: "application/cbor",
headers: {
"smithy-protocol": "rpc-v2-cbor",
"Content-Type": "application/cbor"
"Content-Type": "application/cbor",
"Accept": "application/cbor"
},
requireHeaders: [
"Content-Length"
Expand All @@ -136,7 +138,8 @@ apply RpcV2CborLists @httpRequestTests([
bodyMediaType: "application/cbor",
headers: {
"smithy-protocol": "rpc-v2-cbor",
"Content-Type": "application/cbor"
"Content-Type": "application/cbor",
"Accept": "application/cbor"
},
requireHeaders: [
"Content-Length"
Expand All @@ -155,7 +158,8 @@ apply RpcV2CborLists @httpRequestTests([
bodyMediaType: "application/cbor",
headers: {
"smithy-protocol": "rpc-v2-cbor",
"Content-Type": "application/cbor"
"Content-Type": "application/cbor",
"Accept": "application/cbor"
},
requireHeaders: [
"Content-Length"
Expand All @@ -175,7 +179,8 @@ apply RpcV2CborLists @httpRequestTests([
bodyMediaType: "application/cbor",
headers: {
"smithy-protocol": "rpc-v2-cbor",
"Content-Type": "application/cbor"
"Content-Type": "application/cbor",
"Accept": "application/cbor"
},
requireHeaders: [
"Content-Length"
Expand Down Expand Up @@ -343,7 +348,8 @@ structure StructureListMember {
bodyMediaType: "application/cbor",
headers: {
"smithy-protocol": "rpc-v2-cbor",
"Content-Type": "application/cbor"
"Content-Type": "application/cbor",
"Accept": "application/cbor"
},
requireHeaders: [
"Content-Length"
Expand All @@ -364,7 +370,8 @@ structure StructureListMember {
bodyMediaType: "application/cbor",
headers: {
"smithy-protocol": "rpc-v2-cbor",
"Content-Type": "application/cbor"
"Content-Type": "application/cbor",
"Accept": "application/cbor"
},
requireHeaders: [
"Content-Length"
Expand Down
24 changes: 16 additions & 8 deletions smithy-protocol-tests/model/rpcv2Cbor/cbor-maps.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ apply RpcV2CborDenseMaps @httpRequestTests([
bodyMediaType: "application/cbor",
headers: {
"smithy-protocol": "rpc-v2-cbor",
"Content-Type": "application/cbor"
"Content-Type": "application/cbor",
"Accept": "application/cbor"
},
requireHeaders: [
"Content-Length"
Expand All @@ -55,7 +56,8 @@ apply RpcV2CborDenseMaps @httpRequestTests([
bodyMediaType: "application/cbor",
headers: {
"smithy-protocol": "rpc-v2-cbor",
"Content-Type": "application/cbor"
"Content-Type": "application/cbor",
"Accept": "application/cbor"
},
requireHeaders: [
"Content-Length"
Expand All @@ -79,7 +81,8 @@ apply RpcV2CborDenseMaps @httpRequestTests([
bodyMediaType: "application/cbor",
headers: {
"smithy-protocol": "rpc-v2-cbor",
"Content-Type": "application/cbor"
"Content-Type": "application/cbor",
"Accept": "application/cbor"
},
requireHeaders: [
"Content-Length"
Expand Down Expand Up @@ -222,7 +225,8 @@ apply RpcV2CborSparseMaps @httpRequestTests([
bodyMediaType: "application/cbor",
headers: {
"smithy-protocol": "rpc-v2-cbor",
"Content-Type": "application/cbor"
"Content-Type": "application/cbor",
"Accept": "application/cbor"
},
requireHeaders: [
"Content-Length"
Expand All @@ -248,7 +252,8 @@ apply RpcV2CborSparseMaps @httpRequestTests([
bodyMediaType: "application/cbor",
headers: {
"smithy-protocol": "rpc-v2-cbor",
"Content-Type": "application/cbor"
"Content-Type": "application/cbor",
"Accept": "application/cbor"
},
requireHeaders: [
"Content-Length"
Expand Down Expand Up @@ -278,7 +283,8 @@ apply RpcV2CborSparseMaps @httpRequestTests([
bodyMediaType: "application/cbor",
headers: {
"smithy-protocol": "rpc-v2-cbor",
"Content-Type": "application/cbor"
"Content-Type": "application/cbor",
"Accept": "application/cbor"
},
requireHeaders: [
"Content-Length"
Expand All @@ -300,7 +306,8 @@ apply RpcV2CborSparseMaps @httpRequestTests([
bodyMediaType: "application/cbor",
headers: {
"smithy-protocol": "rpc-v2-cbor",
"Content-Type": "application/cbor"
"Content-Type": "application/cbor",
"Accept": "application/cbor"
},
requireHeaders: [
"Content-Length"
Expand All @@ -323,7 +330,8 @@ apply RpcV2CborSparseMaps @httpRequestTests([
bodyMediaType: "application/cbor",
headers: {
"smithy-protocol": "rpc-v2-cbor",
"Content-Type": "application/cbor"
"Content-Type": "application/cbor",
"Accept": "application/cbor"
},
requireHeaders: [
"Content-Length"
Expand Down
65 changes: 53 additions & 12 deletions smithy-protocol-tests/model/rpcv2Cbor/cbor-structs.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ use smithy.test#httpResponseTests
documentation: "Serializes simple scalar properties",
headers: {
"smithy-protocol": "rpc-v2-cbor",
"Content-Type": "application/cbor"
"Content-Type": "application/cbor",
"Accept": "application/cbor"
}
requireHeaders: [
"Content-Length"
Expand Down Expand Up @@ -44,7 +45,8 @@ use smithy.test#httpResponseTests
a key encoded using an indefinite length string.""",
headers: {
"smithy-protocol": "rpc-v2-cbor",
"Content-Type": "application/cbor"
"Content-Type": "application/cbor",
"Accept": "application/cbor"
}
requireHeaders: [
"Content-Length"
Expand Down Expand Up @@ -77,7 +79,8 @@ use smithy.test#httpResponseTests
bodyMediaType: "application/cbor",
headers: {
"smithy-protocol": "rpc-v2-cbor",
"Content-Type": "application/cbor"
"Content-Type": "application/cbor",
"Accept": "application/cbor"
}
requireHeaders: [
"Content-Length"
Expand All @@ -97,7 +100,8 @@ use smithy.test#httpResponseTests
bodyMediaType: "application/cbor",
headers: {
"smithy-protocol": "rpc-v2-cbor",
"Content-Type": "application/cbor"
"Content-Type": "application/cbor",
"Accept": "application/cbor"
}
requireHeaders: [
"Content-Length"
Expand All @@ -111,7 +115,8 @@ use smithy.test#httpResponseTests
documentation: "Supports handling NaN float values.",
headers: {
"smithy-protocol": "rpc-v2-cbor",
"Content-Type": "application/cbor"
"Content-Type": "application/cbor",
"Accept": "application/cbor"
}
requireHeaders: [
"Content-Length"
Expand All @@ -131,7 +136,8 @@ use smithy.test#httpResponseTests
documentation: "Supports handling Infinity float values.",
headers: {
"smithy-protocol": "rpc-v2-cbor",
"Content-Type": "application/cbor"
"Content-Type": "application/cbor",
"Accept": "application/cbor"
}
requireHeaders: [
"Content-Length"
Expand All @@ -151,7 +157,8 @@ use smithy.test#httpResponseTests
documentation: "Supports handling Infinity float values.",
headers: {
"smithy-protocol": "rpc-v2-cbor",
"Content-Type": "application/cbor"
"Content-Type": "application/cbor",
"Accept": "application/cbor"
}
requireHeaders: [
"Content-Length"
Expand All @@ -171,7 +178,8 @@ use smithy.test#httpResponseTests
documentation: "The server should be capable of deserializing indefinite length text strings.",
headers: {
"smithy-protocol": "rpc-v2-cbor",
"Content-Type": "application/cbor"
"Content-Type": "application/cbor",
"Accept": "application/cbor"
}
requireHeaders: [
"Content-Length"
Expand All @@ -191,7 +199,8 @@ use smithy.test#httpResponseTests
documentation: "The server should be capable of deserializing indefinite length byte strings.",
headers: {
"smithy-protocol": "rpc-v2-cbor",
"Content-Type": "application/cbor"
"Content-Type": "application/cbor",
"Accept": "application/cbor"
}
requireHeaders: [
"Content-Length"
Expand All @@ -211,7 +220,8 @@ use smithy.test#httpResponseTests
documentation: "Supports upcasting from a smaller byte representation of the same data type.",
headers: {
"smithy-protocol": "rpc-v2-cbor",
"Content-Type": "application/cbor"
"Content-Type": "application/cbor",
"Accept": "application/cbor"
}
requireHeaders: [
"Content-Length"
Expand All @@ -238,7 +248,8 @@ use smithy.test#httpResponseTests
generated against an older Smithy model.""",
headers: {
"smithy-protocol": "rpc-v2-cbor",
"Content-Type": "application/cbor"
"Content-Type": "application/cbor",
"Accept": "application/cbor"
}
requireHeaders: [
"Content-Length"
Expand All @@ -260,6 +271,35 @@ use smithy.test#httpResponseTests
blobValue: "foo"
},
appliesTo: "server"
},
{
id: "RpcV2CborServersShouldHandleNoAcceptHeader",
protocol: rpcv2Cbor,
documentation: "Servers should tolerate requests without an Accept header set.",
headers: {
"smithy-protocol": "rpc-v2-cbor",
"Content-Type": "application/cbor"
}
requireHeaders: [
"Content-Length"
],
method: "POST",
bodyMediaType: "application/cbor",
uri: "/service/RpcV2Protocol/operation/SimpleScalarProperties",
body: "v2lieXRlVmFsdWUFa2RvdWJsZVZhbHVl+z/+OVgQYk3TcWZhbHNlQm9vbGVhblZhbHVl9GpmbG9hdFZhbHVl+kD0AABsaW50ZWdlclZhbHVlGQEAaWxvbmdWYWx1ZRkmkWpzaG9ydFZhbHVlGSaqa3N0cmluZ1ZhbHVlZnNpbXBsZXB0cnVlQm9vbGVhblZhbHVl9WlibG9iVmFsdWVDZm9v/w==",
params: {
byteValue: 5,
doubleValue: 1.889,
falseBooleanValue: false,
floatValue: 7.625,
integerValue: 256,
longValue: 9873,
shortValue: 9898,
stringValue: "simple",
trueBooleanValue: true,
blobValue: "foo"
},
appliesTo: "server"
}
])
@httpResponseTests([
Expand Down Expand Up @@ -453,7 +493,8 @@ apply RecursiveShapes @httpRequestTests([
bodyMediaType: "application/cbor",
headers: {
"smithy-protocol": "rpc-v2-cbor",
"Content-Type": "application/cbor"
"Content-Type": "application/cbor",
"Accept": "application/cbor"
},
requireHeaders: [
"Content-Length"
Expand Down
18 changes: 12 additions & 6 deletions smithy-protocol-tests/model/rpcv2Cbor/defaults.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ apply OperationWithDefaults @httpRequestTests([
uri: "/service/RpcV2Protocol/operation/OperationWithDefaults",
headers: {
"smithy-protocol": "rpc-v2-cbor",
"Content-Type": "application/cbor"
"Content-Type": "application/cbor",
"Accept": "application/cbor"
},
requireHeaders: [
"Content-Length"
Expand All @@ -40,7 +41,8 @@ apply OperationWithDefaults @httpRequestTests([
uri: "/service/RpcV2Protocol/operation/OperationWithDefaults",
headers: {
"smithy-protocol": "rpc-v2-cbor",
"Content-Type": "application/cbor"
"Content-Type": "application/cbor",
"Accept": "application/cbor"
},
requireHeaders: [
"Content-Length"
Expand All @@ -60,7 +62,8 @@ apply OperationWithDefaults @httpRequestTests([
uri: "/service/RpcV2Protocol/operation/OperationWithDefaults",
headers: {
"smithy-protocol": "rpc-v2-cbor",
"Content-Type": "application/cbor"
"Content-Type": "application/cbor",
"Accept": "application/cbor"
},
requireHeaders: [
"Content-Length"
Expand Down Expand Up @@ -105,7 +108,8 @@ apply OperationWithDefaults @httpRequestTests([
uri: "/service/RpcV2Protocol/operation/OperationWithDefaults",
headers: {
"smithy-protocol": "rpc-v2-cbor",
"Content-Type": "application/cbor"
"Content-Type": "application/cbor",
"Accept": "application/cbor"
},
requireHeaders: [
"Content-Length"
Expand Down Expand Up @@ -152,7 +156,8 @@ apply OperationWithDefaults @httpRequestTests([
uri: "/service/RpcV2Protocol/operation/OperationWithDefaults",
headers: {
"smithy-protocol": "rpc-v2-cbor",
"Content-Type": "application/cbor"
"Content-Type": "application/cbor",
"Accept": "application/cbor"
},
requireHeaders: [
"Content-Length"
Expand All @@ -174,7 +179,8 @@ apply OperationWithDefaults @httpRequestTests([
uri: "/service/RpcV2Protocol/operation/OperationWithDefaults",
headers: {
"smithy-protocol": "rpc-v2-cbor",
"Content-Type": "application/cbor"
"Content-Type": "application/cbor",
"Accept": "application/cbor"
},
requireHeaders: [
"Content-Length"
Expand Down
Loading
Loading