mirror of
https://github.com/RGBCube/serenity
synced 2025-05-18 21:25:07 +00:00
ProtocolServer: Implement and handle download progress
Also updates `pro` to display download progress and speed on stderr
This commit is contained in:
parent
c6825a96c7
commit
06cf9d3fb7
14 changed files with 97 additions and 22 deletions
|
@ -156,11 +156,23 @@ void HttpJob::on_socket_connected()
|
|||
m_received_size += payload.size();
|
||||
|
||||
auto content_length_header = m_headers.get("Content-Length");
|
||||
Optional<u32> content_length {};
|
||||
|
||||
if (content_length_header.has_value()) {
|
||||
bool ok;
|
||||
auto content_length = content_length_header.value().to_uint(ok);
|
||||
if (ok && m_received_size >= content_length) {
|
||||
m_received_size = content_length;
|
||||
auto length = content_length_header.value().to_uint(ok);
|
||||
if (ok)
|
||||
content_length = length;
|
||||
}
|
||||
|
||||
deferred_invoke([this, content_length](auto&) {
|
||||
did_progress(content_length, m_received_size);
|
||||
});
|
||||
|
||||
if (content_length.has_value()) {
|
||||
auto length = content_length.value();
|
||||
if (m_received_size >= length) {
|
||||
m_received_size = length;
|
||||
finish_up();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue