Skip to content

Commit 267f073

Browse files
committed
bind out write data API
1 parent e28ccc6 commit 267f073

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

include/aws/crt/http/HttpConnection.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <aws/crt/Types.h>
1111
#include <aws/crt/io/Bootstrap.h>
1212
#include <aws/crt/io/SocketOptions.h>
13+
#include <aws/crt/io/Stream.h>
1314
#include <aws/crt/io/TlsOptions.h>
1415

1516
#include <functional>
@@ -118,6 +119,11 @@ namespace Aws
118119
* See `OnStreamComplete` for more info. This value can be empty.
119120
*/
120121
OnStreamComplete onStreamComplete;
122+
123+
/**
124+
* See `UseManualDataWrites` for more info. If true the write data API must be used to provide data.
125+
*/
126+
bool UseManualDataWrites;
121127
};
122128

123129
/**
@@ -216,6 +222,11 @@ namespace Aws
216222
*/
217223
bool Activate() noexcept;
218224

225+
int WriteData(std::shared_ptr<Aws::Crt::Io::InputStream> stream,
226+
aws_http_stream_write_complete_fn* onComplete,
227+
void* userData,
228+
bool endStream = false) noexcept;
229+
219230
private:
220231
HttpClientStream(const std::shared_ptr<HttpClientConnection> &connection) noexcept;
221232

source/http/HttpConnection.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ namespace Aws
202202
options.on_response_headers = HttpStream::s_onIncomingHeaders;
203203
options.on_response_header_block_done = HttpStream::s_onIncomingHeaderBlockDone;
204204
options.on_complete = HttpStream::s_onStreamComplete;
205+
options.use_manual_data_writes = requestOptions.UseManualDataWrites;
205206

206207
/* Do the same ref counting trick we did with HttpClientConnection. We need to maintain a reference
207208
* internally (regardless of what the user does), until the Stream shuts down. */
@@ -361,6 +362,21 @@ namespace Aws
361362
return true;
362363
}
363364

365+
int HttpClientStream::WriteData(std::shared_ptr<Aws::Crt::Io::InputStream> stream,
366+
aws_http_stream_write_complete_fn* onComplete,
367+
void* userData,
368+
bool endStream ) noexcept
369+
{
370+
struct aws_http_stream_write_data_options options;
371+
AWS_ZERO_STRUCT(options);
372+
options.data = stream->GetUnderlyingStream();
373+
options.end_stream = endStream;
374+
options.on_complete = onComplete;
375+
options.user_data = userData;
376+
377+
return aws_http_stream_write_data(m_stream, &options);
378+
}
379+
364380
void HttpStream::UpdateWindow(std::size_t incrementSize) noexcept
365381
{
366382
aws_http_stream_update_window(m_stream, incrementSize);

0 commit comments

Comments
 (0)