diff --git a/src/aws-cpp-sdk-core/include/smithy/client/serializer/JsonOutcomeSerializer.h b/src/aws-cpp-sdk-core/include/smithy/client/serializer/JsonOutcomeSerializer.h index 243a1726d629..1874863f6b42 100644 --- a/src/aws-cpp-sdk-core/include/smithy/client/serializer/JsonOutcomeSerializer.h +++ b/src/aws-cpp-sdk-core/include/smithy/client/serializer/JsonOutcomeSerializer.h @@ -52,8 +52,11 @@ namespace smithy {TracingUtils::SMITHY_SERVICE_DIMENSION, serviceName}}); } + /// ClickHouse: the body is a stream that is only read from, and `tellp` of such a stream + /// does not say whether there is anything in it, so `peek` is asked instead, as in + /// `AWSProtocolClient.h`. if (httpOutcome.GetResult()->GetResponseBody().good() && - httpOutcome.GetResult()->GetResponseBody().tellp() > 0) + httpOutcome.GetResult()->GetResponseBody().peek() != std::char_traits::eof()) { JsonValue jsonValue(httpOutcome.GetResult()->GetResponseBody()); if (!jsonValue.WasParseSuccessful()) { diff --git a/src/aws-cpp-sdk-core/include/smithy/client/serializer/XmlOutcomeSerializer.h b/src/aws-cpp-sdk-core/include/smithy/client/serializer/XmlOutcomeSerializer.h index 61b05f8f9c77..0095d8a74be9 100644 --- a/src/aws-cpp-sdk-core/include/smithy/client/serializer/XmlOutcomeSerializer.h +++ b/src/aws-cpp-sdk-core/include/smithy/client/serializer/XmlOutcomeSerializer.h @@ -53,8 +53,11 @@ namespace smithy {{TracingUtils::SMITHY_METHOD_DIMENSION, requestName}, {TracingUtils::SMITHY_SERVICE_DIMENSION, serviceName}}); } + /// ClickHouse: the body is a stream that is only read from, and `tellp` of such a stream + /// does not say whether there is anything in it, so `peek` is asked instead, as in + /// `AWSProtocolClient.h`. if (httpOutcome.GetResult()->GetResponseBody().good() && - httpOutcome.GetResult()->GetResponseBody().tellp() > 0) + httpOutcome.GetResult()->GetResponseBody().peek() != std::char_traits::eof()) { return TracingUtils::MakeCallWithTiming( [&]() -> XmlOutcome { diff --git a/src/aws-cpp-sdk-core/source/client/AWSErrorMarshaller.cpp b/src/aws-cpp-sdk-core/source/client/AWSErrorMarshaller.cpp index 1768fb9423b1..403a42b6050f 100644 --- a/src/aws-cpp-sdk-core/source/client/AWSErrorMarshaller.cpp +++ b/src/aws-cpp-sdk-core/source/client/AWSErrorMarshaller.cpp @@ -91,7 +91,8 @@ AWSError JsonErrorMarshaller::BuildAWSError(const std::shared_ptrHasClientError()) { bool retryable = httpResponse->GetClientErrorType() == CoreErrors::NETWORK_CONNECTION ? true : false; error = AWSError(httpResponse->GetClientErrorType(), "", httpResponse->GetClientErrorMessage(), retryable); - } else if (!httpResponse->GetResponseBody() || httpResponse->GetResponseBody().tellp() < 1) { + } else if (!httpResponse->GetResponseBody() || httpResponse->GetResponseBody().peek() == std::char_traits::eof()) { + /// ClickHouse: `peek` instead of `tellp`, which a stream that is only read from does not answer. auto responseCode = httpResponse->GetResponseCode(); auto errorCode = GuessBodylessErrorType(responseCode); @@ -175,8 +176,9 @@ AWSError XmlErrorMarshaller::BuildAWSError(const std::shared_ptrGetClientErrorType() == CoreErrors::NETWORK_CONNECTION ? true : false; error = AWSError(httpResponse->GetClientErrorType(), "", httpResponse->GetClientErrorMessage(), retryable); } - else if (!httpResponse->GetResponseBody() || httpResponse->GetResponseBody().tellp() < 1) + else if (!httpResponse->GetResponseBody() || httpResponse->GetResponseBody().peek() == std::char_traits::eof()) { + /// ClickHouse: `peek` instead of `tellp`, which a stream that is only read from does not answer. auto responseCode = httpResponse->GetResponseCode(); auto errorCode = GuessBodylessErrorType(responseCode); @@ -511,7 +513,8 @@ AWSError RpcV2ErrorMarshaller::BuildAWSError(const std::shared_ptrHasClientError()) { bool retryable = httpResponse->GetClientErrorType() == CoreErrors::NETWORK_CONNECTION ? true : false; error = AWSError(httpResponse->GetClientErrorType(), "", httpResponse->GetClientErrorMessage(), retryable); - } else if (!httpResponse->GetResponseBody() || httpResponse->GetResponseBody().tellp() < 1) { + } else if (!httpResponse->GetResponseBody() || httpResponse->GetResponseBody().peek() == std::char_traits::eof()) { + /// ClickHouse: `peek` instead of `tellp`, which a stream that is only read from does not answer. auto responseCode = httpResponse->GetResponseCode(); auto errorCode = GuessBodylessErrorType(responseCode);