mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 19:58:11 +00:00
LibGemini: Add a response length helper to Gemini::Job
Unlike HTTP responses, Gemini responses do not have a length header or a delimiter for the end of a response. A response simply continues until the connection is closed and its length is the number of bytes received. So, the response length method only returns the result if it has finished
This commit is contained in:
parent
5b45b26613
commit
0245a62f81
2 changed files with 11 additions and 0 deletions
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
#include <AK/Debug.h>
|
||||
#include <AK/Error.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibGemini/GeminiResponse.h>
|
||||
#include <LibGemini/Job.h>
|
||||
|
@ -223,4 +224,12 @@ void Job::finish_up()
|
|||
did_finish(move(response));
|
||||
});
|
||||
}
|
||||
|
||||
ErrorOr<size_t> Job::response_length() const
|
||||
{
|
||||
if (m_state != State::Finished)
|
||||
return AK::Error::from_string_literal("Gemini response has not finished");
|
||||
|
||||
return m_received_size;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue