Skip to content
Open
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
1 change: 1 addition & 0 deletions src/aws-cpp-sdk-core/include/aws/core/client/CoreErrors.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ namespace Aws
REQUEST_TIMEOUT = 24,
NOT_INITIALIZED = 25,
MEMORY_ALLOCATION = 26,
NOT_IMPLEMENTED = 27,

NETWORK_CONNECTION = 99, // General failure to send message to service

Expand Down
17 changes: 15 additions & 2 deletions src/aws-cpp-sdk-core/include/aws/core/http/HttpClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@
#pragma once

#include <aws/core/Core_EXPORTS.h>
#include <aws/core/http/HttpConnection.h>
#include <aws/core/utils/Outcome.h>
#include <aws/core/client/AWSError.h>

#include <memory>
#include <atomic>
#include <mutex>
#include <condition_variable>
#include <memory>
#include <mutex>

namespace Aws
{
Expand Down Expand Up @@ -77,6 +80,16 @@ namespace Aws
return !m_bad;
}

using AcquireConnectionOutcome = Aws::Utils::Outcome<std::shared_ptr<Aws::Http::Connection>,
Aws::Client::AWSError<Aws::Client::CoreErrors>>;
virtual AcquireConnectionOutcome AcquireConnection(const std::shared_ptr<HttpRequest>& request) {
AWS_UNREFERENCED_PARAM(request);
return Aws::Client::AWSError<Aws::Client::CoreErrors>{Aws::Client::CoreErrors::NOT_IMPLEMENTED,
"NotImplemented",
"creating a connection is not supported on this http client",
false};
}

protected:
bool m_bad;

Expand Down
25 changes: 25 additions & 0 deletions src/aws-cpp-sdk-core/include/aws/core/http/HttpClientStream.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/

#pragma once
#include <aws/core/utils/memory/stl/AWSStreamFwd.h>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super nit: we are transitively including AWS_CORE_API somewhere and that's why AWS_CORE_API works but we should explicitly include #include <aws/core/Core_EXPORTS.h>


#include <functional>
#include <memory>

namespace Aws {
namespace Http {
class HttpResponse;
class AWS_CORE_API ClientStream {
public:
virtual ~ClientStream() = default;
virtual bool Activate() = 0;
virtual int WriteData(std::shared_ptr<Aws::IOStream> stream,
const std::function<void(int errorCode)>& onComplete,
bool endStream = false) = 0;
virtual std::shared_ptr<Aws::Http::HttpResponse> GetResponse() const = 0;
};
} // namespace Http
} // namespace Aws
23 changes: 23 additions & 0 deletions src/aws-cpp-sdk-core/include/aws/core/http/HttpConnection.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/

#pragma once
#include <aws/core/http/HttpClientStream.h>

#include <functional>
#include <memory>

namespace Aws {
namespace Http {
class HttpRequest;
class AWS_CORE_API Connection {
public:
virtual ~Connection() = default;
virtual std::shared_ptr<Aws::Http::ClientStream> NewClientStream(
const std::shared_ptr<HttpRequest>& request,
std::function<void(int errorCode)> onStreamComplete) = 0;
};
} // namespace Http
} // namespace Aws
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ namespace Aws

bool IsDefaultAwsHttpClient() const override { return true; }

AcquireConnectionOutcome AcquireConnection(const std::shared_ptr<HttpRequest>& request) override;

private:
// Yeah, I know, but someone made MakeRequest() const and didn't think about the fact that
// making an HTTP request most certainly mutates state. It was me. I'm the person that did that, and
Expand Down
Loading
Loading