CLOUD: Fix minor Reader-related bugs

This commit is contained in:
Alexander Tkachev 2016-07-08 13:42:48 +06:00
parent b69cc3effb
commit f3ee9e3272
4 changed files with 9 additions and 7 deletions

View File

@ -65,7 +65,8 @@ MODULE_OBJS += \
networking/sdl_net/handlers/filespagehandler.o \
networking/sdl_net/handlers/indexpagehandler.o \
networking/sdl_net/handlers/resourcehandler.o \
networking/sdl_net/localwebserver.o
networking/sdl_net/localwebserver.o \
networking/sdl_net/reader.o
endif
ifdef USE_ELF_LOADER

View File

@ -44,7 +44,8 @@ void Client::open(SDLNet_SocketSet set, TCPsocket socket) {
_state = READING_HEADERS;
_socket = socket;
_set = set;
_reader = Reader();
Reader cleanReader;
_reader = cleanReader;
_handler = nullptr;
if (set) {
int numused = SDLNet_TCP_AddSocket(set, socket);

View File

@ -157,7 +157,7 @@ bool Reader::readRequest() {
bts += readOne();
if (bts == "--") break;
if (bts == "\r\n") continue;
warning("strange bytes: \"%s\"", bts);
warning("strange bytes: \"%s\"", bts.c_str());
} else {
warning("strange ending");
break;
@ -327,7 +327,7 @@ void Reader::parseQueryParameters() {
} else key += _query[i];
} else {
if (_query[i] == '&') {
if (_queryParameters.contains(key)) warning("Query parameter \"%s\" is already set!");
if (_queryParameters.contains(key)) warning("Query parameter \"%s\" is already set!", key.c_str());
else _queryParameters[key] = LocalWebserver::urlDecode(value);
readingKey = true;
key = "";
@ -336,7 +336,7 @@ void Reader::parseQueryParameters() {
}
if (!key.empty()) {
if (_queryParameters.contains(key)) warning("Query parameter \"%s\" is already set!");
if (_queryParameters.contains(key)) warning("Query parameter \"%s\" is already set!", key.c_str());
else _queryParameters[key] = LocalWebserver::urlDecode(value);
}
}

View File

@ -79,8 +79,8 @@ class Reader {
void makeWindow(uint32 size);
void freeWindow();
bool Reader::readOneByteInStream(Common::WriteStream *stream, const Common::String &boundary);
bool Reader::readOneByteInString(Common::String &buffer, const Common::String &boundary);
bool readOneByteInStream(Common::WriteStream *stream, const Common::String &boundary);
bool readOneByteInString(Common::String &buffer, const Common::String &boundary);
byte readOne();
uint32 bytesLeft();