33#include <jau/test/catch2_ext.hpp>
54 const std::string
CRLF =
"\r\n";
58 "TABLE_TYPE='Vector'\n"
60 "REF_PLANE='Ecliptic'\n"
61 "START_TIME='2024-01-01 00:00:00'\n"
62 "STOP_TIME='2024-01-01 00:00:01'\n";
73 if( catch_auto_run ) {
78 postReq->header.emplace(
"Content-Type",
"multipart/form-data; boundary="+
HttpBoundary);
80 postReq->body.append(
"Content-Disposition: form-data; name=\"format\"").append(
CRLF).append(
CRLF);
81 postReq->body.append(
"text").append(
CRLF);
83 postReq->body.append(R
"(Content-Disposition: form-data; name="input"; filename="a.cmd")").append(CRLF);
84 postReq->body.append("Content-type: application/octet-stream").append(
CRLF).append(
CRLF);
92 std::cout <<
"XXX: len " << len <<
"/" << response.
content_length <<
", final " << is_final << std::endl;
93 if(
nullptr != data && len > 0 ) {
94 std::string d(data, data+len);
95 std::cout <<
" > " << d << std::endl;
100 REQUIRE(
nullptr != res );
104 jau::PLAIN_PRINT(
true,
"test01_post_sync_ok.X Done: consumed %" PRIu64
" / total %" PRIu64
" / content_len %" PRIu64
", result %d",
105 consumed_byte_count.
load(), res->total_read, res->content_length, (
int)res->result.load() );
107 REQUIRE( res->header_resp.completed() ==
true );
108 REQUIRE( res->header_resp.response_code() == 200 );
109 if( res->has_content_length ) {
110 REQUIRE( res->content_length == consumed_byte_count );
112 REQUIRE( res->total_read == consumed_byte_count );
113 REQUIRE( res->success() );
121 if( catch_auto_run ) {
126 postReq->header.emplace(
"Content-Type",
"multipart/form-data; boundary="+
HttpBoundary);
128 postReq->body.append(
"Content-Disposition: form-data; name=\"format\"").append(
CRLF).append(
CRLF);
129 postReq->body.append(
"text").append(
CRLF);
131 postReq->body.append(R
"(Content-Disposition: form-data; name="input"; filename="a.cmd")").append(CRLF);
132 postReq->body.append("Content-type: application/octet-stream").append(
CRLF).append(
CRLF);
140 std::cout <<
"XXX: len " << len <<
"/" << response.
content_length <<
", final " << is_final << std::endl;
141 if(
nullptr != data && len > 0 ) {
142 std::string d(data, data+len);
143 std::cout <<
" > " << d << std::endl;
148 REQUIRE(
nullptr != res );
153 jau::PLAIN_PRINT(
true,
"test11_post_async_ok.X Done: consumed %" PRIu64
" / total %" PRIu64
" / content_len %" PRIu64
", result %d",
154 consumed_byte_count.
load(), res->total_read.load(), res->content_length.load(), (
int)res->result.load() );
156 REQUIRE( res->header_resp.completed() ==
true );
157 REQUIRE( res->header_resp.response_code() == 200 );
158 if( res->has_content_length ) {
159 REQUIRE( res->content_length == consumed_byte_count );
162 REQUIRE( res->total_read == consumed_byte_count );
163 REQUIRE( res->success() );
const std::string HorizonCmd01
~TestHttpStream01()=default
void test11_post_async_ok()
const std::string HttpBoundary
TestHttpStream01()=default
void test01_post_sync_ok()
const std::string HttpBoundarySep
const std::string url_input_root
ordered_atomic< uint64_t, std::memory_order_relaxed > relaxed_atomic_uint64
Relaxed non-SC atomic integral scalar uint64_t.
AsyncStreamResponseRef read_url_stream_async(net_tk_handle handle, const std::string &url, http::PostRequestPtr httpPostReq, ByteRingbuffer *buffer, const AsyncStreamConsumerFunc &consumer_fn) noexcept
Asynchronous URL stream reader using the given AsyncStreamConsumerFunc consumer_fn.
SyncStreamResponseRef read_url_stream_sync(net_tk_handle handle, const std::string &url, http::PostRequestPtr httpPostReq, ByteRingbuffer *buffer, const SyncStreamConsumerFunc &consumer_fn) noexcept
Synchronous URL stream reader using the given SyncStreamConsumerFunc consumer_fn.
net_tk_handle create_net_tk_handle() noexcept
creates a reusable handle, free with free_net_tk_handle() after use.
std::shared_ptr< SyncStreamResponse > SyncStreamResponseRef
std::shared_ptr< AsyncStreamResponse > AsyncStreamResponseRef
void free_net_tk_handle(net_tk_handle handle) noexcept
frees a handle after use created by create_net_tk_handle()
bool protocol_supported(const std::string_view &uri) noexcept
Returns true if the uri-scheme of given uri matches a supported by libcurl network protocols otherwis...
std::unique_ptr< PostRequest > PostRequestPtr
void PLAIN_PRINT(const bool printPrefix, const char *format,...) noexcept
Use for unconditional plain messages, prefix '[elapsed_time] ' if printPrefix == true.
Asynchronous stream response.
relaxed_atomic_uint64 content_length
content_length tracking the content_length
Synchronous stream response.
uint64_t content_length
content_length tracking the content_length
CXX_ALWAYS_INLINE _Tp fetch_add(_Tp __i) noexcept
CXX_ALWAYS_INLINE _Tp load() const noexcept
METHOD_AS_TEST_CASE(TestHttpStream01::test01_post_sync_ok, "TestIOStream01 - test01_post_sync_ok")