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

FIX httpfs preadv return wrong length of partial-read http body. #254

Merged
merged 1 commit into from
Nov 17, 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
3 changes: 1 addition & 2 deletions fs/httpfs/httpfs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,7 @@ class HttpFile : public fs::VirtualReadOnlyFile {
VALUE(url), VALUE(offset), VALUE(ret));
}
authorized = true;
headers.try_get("content-length", ret);
return ret;
return writer.written;
}

int fstat(struct stat* buf) override {
Expand Down
2 changes: 2 additions & 0 deletions net/curl.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,11 @@ class StringWriter {
struct IOVWriter : public IOVector {
using IOVector::IOVector;
size_t drop = 0;
size_t written = 0;
size_t write(const void* buf, size_t size) {
auto actual_count = memcpy_from(
buf, size); // copy from (buf, size) to iovec[] in *this,
written += actual_count;
extract_front(actual_count); // and extract the portion just copied
if (actual_count < size) // means full
{
Expand Down