Skip to content

Commit

Permalink
change http body_writer return type to ssize_t (#197)
Browse files Browse the repository at this point in the history
Signed-off-by: liulanzheng <lanzheng.liulz@alibaba-inc.com>
  • Loading branch information
liulanzheng committed Oct 13, 2023
1 parent 81c6126 commit 90b6abe
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions net/http/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<Request*>; // 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<ssize_t, Request*>; // 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) {
Expand Down
2 changes: 1 addition & 1 deletion net/http/test/client_function_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
Expand Down
6 changes: 3 additions & 3 deletions net/http/test/server_function_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 90b6abe

Please sign in to comment.