mirror of
https://github.com/LibreOffice/online.git
synced 2025-08-03 16:05:07 +00:00
Initial chunked transfer encoding.
Important for convert-to on larger documents and/or with newer curls. Change-Id: Id18be6d22741a3af7cee39a069c509e4f662977b
This commit is contained in:
@ -949,9 +949,21 @@ public:
|
||||
return socket;
|
||||
}
|
||||
|
||||
/// Messages can be in chunks, only parts of message being valid.
|
||||
struct MessageMap {
|
||||
MessageMap() : _headerSize(0), _messageSize(0) {}
|
||||
/// Size of HTTP headers
|
||||
size_t _headerSize;
|
||||
/// Entire size of data associated with this message
|
||||
size_t _messageSize;
|
||||
// offset + lengths to collate into the real stream
|
||||
std::vector<std::pair<size_t, size_t>> _spans;
|
||||
};
|
||||
|
||||
/// Remove the first @count bytes from input buffer
|
||||
void eraseFirstInputBytes(size_t count)
|
||||
void eraseFirstInputBytes(const MessageMap &map)
|
||||
{
|
||||
size_t count = map._headerSize;
|
||||
size_t toErase = std::min(count, _inBuffer.size());
|
||||
if (toErase < count)
|
||||
LOG_ERR("#" << getFD() << ": attempted to remove: " << count << " which is > size: " << _inBuffer.size() << " clamped to " << toErase);
|
||||
@ -959,12 +971,16 @@ public:
|
||||
_inBuffer.erase(_inBuffer.begin(), _inBuffer.begin() + count);
|
||||
}
|
||||
|
||||
/// Compacts chunk headers away leaving just the data we want
|
||||
/// returns true if we did any re-sizing/movement of _inBuffer.
|
||||
bool compactChunks(MessageMap *map);
|
||||
|
||||
/// Detects if we have an HTTP header in the provided message and
|
||||
/// populates a request for that.
|
||||
bool parseHeader(const char *clientLoggingName,
|
||||
Poco::MemoryInputStream &message,
|
||||
Poco::Net::HTTPRequest &request,
|
||||
size_t *requestSize = nullptr);
|
||||
MessageMap *map = nullptr);
|
||||
|
||||
/// Get input/output statistics on this stream
|
||||
void getIOStats(uint64_t &sent, uint64_t &recv)
|
||||
@ -985,6 +1001,8 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
std::vector<std::pair<size_t, size_t>> findChunks(Poco::Net::HTTPRequest &request);
|
||||
|
||||
/// Called when a polling event is received.
|
||||
/// @events is the mask of events that triggered the wake.
|
||||
void handlePoll(SocketDisposition &disposition,
|
||||
|
Reference in New Issue
Block a user