aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backends/networking/sdl_net/uploadfileclienthandler.cpp32
-rw-r--r--backends/networking/sdl_net/uploadfileclienthandler.h1
2 files changed, 19 insertions, 14 deletions
diff --git a/backends/networking/sdl_net/uploadfileclienthandler.cpp b/backends/networking/sdl_net/uploadfileclienthandler.cpp
index e2832bcba5..ee02915d6f 100644
--- a/backends/networking/sdl_net/uploadfileclienthandler.cpp
+++ b/backends/networking/sdl_net/uploadfileclienthandler.cpp
@@ -167,18 +167,7 @@ void UploadFileClientHandler::handleBlockContent(Client *client) {
if (client->noMoreContent()) {
// success - redirect back to directory listing
- HandlerUtils::setMessageHandler(
- *client,
- Common::String::format(
- "%s<br/><a href=\"files?path=%s\">%s</a>",
- _("Uploaded successfully!"),
- client->queryParameter("path").c_str(),
- _("Back to parent directory")
- ),
- (client->queryParameter("ajax") == "true" ? "/filesAJAX?path=" : "/files?path=") +
- LocalWebserver::urlEncodeQueryParameterValue(client->queryParameter("path"))
- );
- _state = UFH_STOP;
+ setSuccessHandler(*client);
return;
}
}
@@ -189,9 +178,8 @@ void UploadFileClientHandler::handleBlockContent(Client *client) {
if (_uploadedFiles == 0) {
setErrorMessageHandler(*client, _("No file was passed!"));
} else {
- _state = UFH_STOP;
+ setSuccessHandler(*client);
}
- return;
}
}
@@ -200,4 +188,20 @@ void UploadFileClientHandler::setErrorMessageHandler(Client &client, Common::Str
_state = UFH_ERROR;
}
+void UploadFileClientHandler::setSuccessHandler(Client &client) {
+ // success - redirect back to directory listing
+ HandlerUtils::setMessageHandler(
+ client,
+ Common::String::format(
+ "%s<br/><a href=\"files?path=%s\">%s</a>",
+ _("Uploaded successfully!"),
+ client.queryParameter("path").c_str(),
+ _("Back to parent directory")
+ ),
+ (client.queryParameter("ajax") == "true" ? "/filesAJAX?path=" : "/files?path=") +
+ LocalWebserver::urlEncodeQueryParameterValue(client.queryParameter("path"))
+ );
+ _state = UFH_STOP;
+}
+
} // End of namespace Networking
diff --git a/backends/networking/sdl_net/uploadfileclienthandler.h b/backends/networking/sdl_net/uploadfileclienthandler.h
index 4aa6929888..b6481cf18f 100644
--- a/backends/networking/sdl_net/uploadfileclienthandler.h
+++ b/backends/networking/sdl_net/uploadfileclienthandler.h
@@ -56,6 +56,7 @@ class UploadFileClientHandler: public ClientHandler {
void handleBlockHeaders(Client *client);
void handleBlockContent(Client *client);
void setErrorMessageHandler(Client &client, Common::String message);
+ void setSuccessHandler(Client &client);
public:
UploadFileClientHandler(Common::String parentDirectoryPath);