Skip to content

Commit

Permalink
address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
dayaffe committed Dec 31, 2024
1 parent d579676 commit 9c5123c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ extension CborValidateResponseHeaderMiddleware: Interceptor {
public typealias RequestType = HTTPRequest
public typealias ResponseType = HTTPResponse

public func readBeforeDeserialization(context: some BeforeDeserialization<InputType, RequestType, ResponseType>) async throws {
public func readBeforeDeserialization(
context: some BeforeDeserialization<InputType, RequestType, ResponseType>
) async throws {
let response = context.getResponse()
let smithyProtocolHeader = response.headers.value(for: "smithy-protocol")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ public struct RpcV2CborError: BaseError {

@_spi(SmithyReadWrite)
public init(httpResponse: HTTPResponse, responseReader: Reader, noErrorWrapping: Bool, code: String? = nil) throws {

// Improve this code
switch responseReader.cborValue {
case .map(let errorDetails):
if case let .text(errorCode) = errorDetails["__type"] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,20 @@ class RpcV2CborProtocolGenerator : AWSHTTPBindingProtocolGenerator(RpcV2CborCust
override fun addProtocolSpecificMiddleware(ctx: ProtocolGenerator.GenerationContext, operation: OperationShape) {
super.addProtocolSpecificMiddleware(ctx, operation)

// Original instance of OperationInputBodyMiddleware checks if there is an HTTP Body, but for AWSJson protocols
// we always need to have an InputBodyMiddleware
operationMiddleware.removeMiddleware(operation, "OperationInputBodyMiddleware")
operationMiddleware.appendMiddleware(operation, OperationInputBodyMiddleware(ctx.model, ctx.symbolProvider, true))

val hasEventStreamResponse = ctx.model.expectShape(operation.outputShape).hasTrait<StreamingTrait>()
val hasEventStreamRequest = ctx.model.expectShape(operation.inputShape).hasTrait<StreamingTrait>()

// Determine the value of the Accept header
// Determine the value of the Accept header based on output shape
val acceptHeaderValue = if (hasEventStreamResponse) {
"application/vnd.amazon.eventstream"
} else {
"application/cbor"
}

// Determine the value of the Content-Type header
// Determine the value of the Content-Type header based on input shape
val contentTypeValue = if (hasEventStreamRequest) {
"application/vnd.amazon.eventstream"
} else {
Expand Down

0 comments on commit 9c5123c

Please sign in to comment.