Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change http body_writer return type to ssize_t #197

Merged
merged 1 commit into from
Oct 13, 2023
Merged
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
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