summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibHTTP/Job.cpp
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2022-04-15 13:33:02 +0100
committerTim Flynn <trflynn89@pm.me>2022-04-16 13:27:51 -0400
commit3b1e063d30d915826949ce13e069761d7a32e8a5 (patch)
treeea04c82daeea29fda7505a5a85e750d208e22457 /Userland/Libraries/LibHTTP/Job.cpp
parent6654efcd8207811bf3442368bf3cba04ac4ec5ae (diff)
downloadserenity-3b1e063d30d915826949ce13e069761d7a32e8a5.zip
LibCore+Everywhere: Make Core::Stream::read() return Bytes
A mistake I've repeatedly made is along these lines: ```c++ auto nread = TRY(source_file->read(buffer)); TRY(destination_file->write(buffer)); ``` It's a little clunky to have to create a Bytes or StringView from the buffer's data pointer and the nread, and easy to forget and just use the buffer. So, this patch changes the read() function to return a Bytes of the data that were just read. The other read_foo() methods will be modified in the same way in subsequent commits. Fixes #13687
Diffstat (limited to 'Userland/Libraries/LibHTTP/Job.cpp')
-rw-r--r--Userland/Libraries/LibHTTP/Job.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/Userland/Libraries/LibHTTP/Job.cpp b/Userland/Libraries/LibHTTP/Job.cpp
index 6ae5ecf281..f39972b4eb 100644
--- a/Userland/Libraries/LibHTTP/Job.cpp
+++ b/Userland/Libraries/LibHTTP/Job.cpp
@@ -172,7 +172,7 @@ ErrorOr<ByteBuffer> Job::receive(size_t size)
auto result = m_socket->read(buffer);
if (result.is_error() && result.error().is_errno() && result.error().code() == EINTR)
continue;
- nread = TRY(result);
+ nread = TRY(result).size();
break;
} while (true);
return buffer.slice(0, nread);