diff options
author | Alexander Tkachev | 2016-07-06 19:48:59 +0600 |
---|---|---|
committer | Alexander Tkachev | 2016-08-24 16:07:55 +0600 |
commit | 89a1a549822dee5b18d799cd9b8e5a58190aa49d (patch) | |
tree | e40e5a70aef513f02e92a1cc13468ba1f4c44324 /backends | |
parent | b40bfaa046370a2eeadcce1236f518315e8ada01 (diff) | |
download | scummvm-rg350-89a1a549822dee5b18d799cd9b8e5a58190aa49d.tar.gz scummvm-rg350-89a1a549822dee5b18d799cd9b8e5a58190aa49d.tar.bz2 scummvm-rg350-89a1a549822dee5b18d799cd9b8e5a58190aa49d.zip |
CLOUD: Update GetClientHandler's buffer
It's not static now and it's increased to 1 MB.
Diffstat (limited to 'backends')
-rw-r--r-- | backends/networking/sdl_net/getclienthandler.cpp | 21 | ||||
-rw-r--r-- | backends/networking/sdl_net/getclienthandler.h | 3 |
2 files changed, 15 insertions, 9 deletions
diff --git a/backends/networking/sdl_net/getclienthandler.cpp b/backends/networking/sdl_net/getclienthandler.cpp index 0e73a54912..cdbcd96c61 100644 --- a/backends/networking/sdl_net/getclienthandler.cpp +++ b/backends/networking/sdl_net/getclienthandler.cpp @@ -25,9 +25,14 @@ namespace Networking { -GetClientHandler::GetClientHandler(Common::SeekableReadStream *stream): _responseCode(200), _headersPrepared(false), _stream(stream) {} +GetClientHandler::GetClientHandler(Common::SeekableReadStream *stream): + _responseCode(200), _headersPrepared(false), + _stream(stream), _buffer(new byte[CLIENT_HANDLER_BUFFER_SIZE]) {} -GetClientHandler::~GetClientHandler() { delete _stream; } +GetClientHandler::~GetClientHandler() { + delete _stream; + delete[] _buffer; +} const char *GetClientHandler::responseMessage(long responseCode) { switch (responseCode) { @@ -118,16 +123,14 @@ void GetClientHandler::prepareHeaders() { void GetClientHandler::handle(Client *client) { if (!client) return; if (!_headersPrepared) prepareHeaders(); - - const int kBufSize = 16 * 1024; - char buf[kBufSize]; + uint32 readBytes; // send headers first if (_headers.size() > 0) { readBytes = _headers.size(); - if (readBytes > kBufSize) readBytes = kBufSize; - memcpy(buf, _headers.c_str(), readBytes); + if (readBytes > CLIENT_HANDLER_BUFFER_SIZE) readBytes = CLIENT_HANDLER_BUFFER_SIZE; + memcpy(_buffer, _headers.c_str(), readBytes); _headers.erase(0, readBytes); } else { if (!_stream) { @@ -135,11 +138,11 @@ void GetClientHandler::handle(Client *client) { return; } - readBytes = _stream->read(buf, kBufSize); + readBytes = _stream->read(_buffer, CLIENT_HANDLER_BUFFER_SIZE); } if (readBytes != 0) - if (client->send(buf, readBytes) != readBytes) { + if (client->send(_buffer, readBytes) != readBytes) { warning("GetClientHandler: unable to send all bytes to the client"); client->close(); return; diff --git a/backends/networking/sdl_net/getclienthandler.h b/backends/networking/sdl_net/getclienthandler.h index f434df1a45..3486ceef8a 100644 --- a/backends/networking/sdl_net/getclienthandler.h +++ b/backends/networking/sdl_net/getclienthandler.h @@ -30,12 +30,15 @@ namespace Networking { +#define CLIENT_HANDLER_BUFFER_SIZE 1 * 1024 * 1024 + class GetClientHandler: public ClientHandler { Common::HashMap<Common::String, Common::String> _specialHeaders; long _responseCode; bool _headersPrepared; Common::String _headers; Common::SeekableReadStream *_stream; + byte *_buffer; static const char *responseMessage(long responseCode); void prepareHeaders(); |