From 90b6abe15e61b7bb6d4cc8ff86069397fa09cf31 Mon Sep 17 00:00:00 2001 From: Lanzheng Liu Date: Fri, 13 Oct 2023 02:12:42 -0500 Subject: [PATCH] change http body_writer return type to ssize_t (#197) Signed-off-by: liulanzheng --- net/http/client.h | 6 +++--- net/http/test/client_function_test.cpp | 2 +- net/http/test/server_function_test.cpp | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/net/http/client.h b/net/http/client.h index d2affab4..7a767786 100644 --- a/net/http/client.h +++ b/net/http/client.h @@ -48,9 +48,9 @@ class Client : public Object { Response resp; // response int status_code = -1; // status code in response bool enable_proxy; - IStream* body_stream = nullptr; // use body_stream as body - using BodyWriter = Callback; // or call body_writer if body_stream - BodyWriter body_writer = {}; // is not set + IStream* body_stream = nullptr; // use body_stream as body + using BodyWriter = Delegate; // or call body_writer if body_stream + BodyWriter body_writer = {}; // is not set static Operation* create(Client* c, Verb v, std::string_view url, uint16_t buf_size = 64 * 1024 - 1) { diff --git a/net/http/test/client_function_test.cpp b/net/http/test/client_function_test.cpp index 2604fb0e..29151c0d 100644 --- a/net/http/test/client_function_test.cpp +++ b/net/http/test/client_function_test.cpp @@ -186,7 +186,7 @@ TEST(http_client, post) { auto op2 = client->new_operation(Verb::POST, target); DEFER(delete op2); op2->req.headers.content_length(st.st_size); - auto writer = [&](Request *req)-> int { + auto writer = [&](Request *req)-> ssize_t { file->lseek(0, SEEK_SET); return req->write_stream(file, st.st_size); }; diff --git a/net/http/test/server_function_test.cpp b/net/http/test/server_function_test.cpp index a42d5792..e50d547d 100644 --- a/net/http/test/server_function_test.cpp +++ b/net/http/test/server_function_test.cpp @@ -109,7 +109,7 @@ TEST(http_server, post) { DEFER(delete op); op->req.headers.content_length(10); std::string body = "1234567890"; - auto writer = [&](Request *req)-> int { + auto writer = [&](Request *req)-> ssize_t { return req->write(body.data(), body.size()); }; op->body_writer = writer; @@ -343,7 +343,7 @@ TEST(http_server, proxy_handler_post) { DEFER(delete op); std::string body = "1234567890"; op->req.headers.content_length(10); - auto writer = [&](Request *req)-> int { + auto writer = [&](Request *req)-> ssize_t { return req->write(body.data(), body.size()); }; op->body_writer = writer; @@ -405,7 +405,7 @@ TEST(http_server, proxy_handler_post_forward) { DEFER(delete op); std::string body = "1234567890"; op->req.headers.content_length(10); - auto writer = [&](Request *req)-> int { + auto writer = [&](Request *req)-> ssize_t { return req->write(body.data(), body.size()); }; op->body_writer = writer;