diff options
author | Ali Mohammad Pur <ali.mpfard@gmail.com> | 2021-06-29 01:40:18 +0430 |
---|---|---|
committer | Ali Mohammad Pur <Ali.mpfard@gmail.com> | 2021-06-29 01:57:16 +0430 |
commit | 3058ff1500458d02034d76abdfc6b0b1f9b40573 (patch) | |
tree | fb1c036b377ad46772125f340581e57a74c971c9 /Userland/Libraries | |
parent | b12e5de04787680ce53955650b510bae9b26d325 (diff) | |
download | serenity-3058ff1500458d02034d76abdfc6b0b1f9b40573.zip |
LibHTTP: Relax the finish_up() "must be called once" limitation a bit
It's alright for this function to be called multiple times, as it quits
early when a partial flush doesn't empty the download buffer.
Relax the assertion to having scheduled "did_finish()" only once.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibHTTP/Job.cpp | 7 | ||||
-rw-r--r-- | Userland/Libraries/LibHTTP/Job.h | 1 |
2 files changed, 5 insertions, 3 deletions
diff --git a/Userland/Libraries/LibHTTP/Job.cpp b/Userland/Libraries/LibHTTP/Job.cpp index 329e5de23c..72654d51ed 100644 --- a/Userland/Libraries/LibHTTP/Job.cpp +++ b/Userland/Libraries/LibHTTP/Job.cpp @@ -360,7 +360,7 @@ void Job::timer_event(Core::TimerEvent& event) void Job::finish_up() { - VERIFY(m_state != State::Finished); + VERIFY(!m_has_scheduled_finish); m_state = State::Finished; if (!m_can_stream_response) { auto flattened_buffer = ByteBuffer::create_uninitialized(m_received_size); @@ -395,9 +395,10 @@ void Job::finish_up() return; } + m_has_scheduled_finish = true; auto response = HttpResponse::create(m_code, move(m_headers)); - deferred_invoke([this, response](auto&) { - did_finish(move(response)); + deferred_invoke([this, response = move(response)](auto&) { + did_finish(response); }); } } diff --git a/Userland/Libraries/LibHTTP/Job.h b/Userland/Libraries/LibHTTP/Job.h index 83fcfd9613..338d43192f 100644 --- a/Userland/Libraries/LibHTTP/Job.h +++ b/Userland/Libraries/LibHTTP/Job.h @@ -64,6 +64,7 @@ protected: Optional<size_t> m_current_chunk_total_size; bool m_can_stream_response { true }; bool m_should_read_chunk_ending_line { false }; + bool m_has_scheduled_finish { false }; }; } |