mirror of
https://github.com/pocoproject/poco.git
synced 2025-02-20 14:24:35 +01:00
Changed Ajax request detection to prevent browser caching
This commit is contained in:
parent
ae5b44091f
commit
ab07e2cbba
@ -485,9 +485,14 @@ std::string Utility::createURI(const std::map<std::string, std::string>& addPara
|
||||
WebApplication& app = WebApplication::instance();
|
||||
Renderable::ID id = app.getCurrentPage()->id();
|
||||
std::ostringstream uri;
|
||||
uri << "'" << app.getURI().toString() << "?";
|
||||
uri << RequestHandler::KEY_TYPE << "=" << RequestHandler::VAL_AJAX; //mark as AJAX request
|
||||
uri << "&" << RequestHandler::KEY_ID << "=" << id;
|
||||
std::string theUri(app.getURI().toString());
|
||||
if (theUri.empty())
|
||||
theUri = "/";
|
||||
else if (theUri[theUri.length()-1] != '/')
|
||||
theUri.append("/");
|
||||
uri << "'" << theUri;
|
||||
uri << ";"; //mark as AJAX request
|
||||
uri << RequestHandler::KEY_ID << "=" << id;
|
||||
// add optional params
|
||||
bool commaAtEnd = false;
|
||||
std::size_t cnt(1);
|
||||
|
@ -59,8 +59,6 @@ class WebWidgets_API RequestHandler: public Poco::Net::HTTPRequestHandler
|
||||
public:
|
||||
static const std::string KEY_ID; /// key for form param contains id
|
||||
static const std::string KEY_EVID; /// form param containing the event name
|
||||
static const std::string VAL_AJAX; /// value to detect an AJAX request
|
||||
static const std::string KEY_TYPE; /// key identifying the type of request
|
||||
|
||||
RequestHandler(WebApplication& app);
|
||||
/// Creates the RequestHandler, using the given WebApplication.
|
||||
|
@ -56,8 +56,6 @@ namespace WebWidgets {
|
||||
|
||||
const std::string RequestHandler::KEY_ID("id");
|
||||
const std::string RequestHandler::KEY_EVID("evId");
|
||||
const std::string RequestHandler::VAL_AJAX("ajax");
|
||||
const std::string RequestHandler::KEY_TYPE("appinf");
|
||||
|
||||
|
||||
RequestHandler::RequestHandler(WebApplication& app):
|
||||
@ -74,28 +72,21 @@ RequestHandler::~RequestHandler()
|
||||
void RequestHandler::handleRequest(Poco::Net::HTTPServerRequest& request, Poco::Net::HTTPServerResponse& response)
|
||||
{
|
||||
_app.attachToThread();
|
||||
Poco::Net::HTMLForm form(request, request.stream());
|
||||
if (!form.empty())
|
||||
Poco::Net::NameValueCollection args;
|
||||
parseRequest(request, args);
|
||||
if (args.empty())
|
||||
{
|
||||
Poco::Net::NameValueCollection::ConstIterator it = form.find(KEY_TYPE);
|
||||
if (it != form.end())
|
||||
Poco::Net::HTMLForm form(request, request.stream());
|
||||
if (!form.empty())
|
||||
{
|
||||
if (it->second == VAL_AJAX)
|
||||
{
|
||||
form.erase(KEY_TYPE);
|
||||
handleAjaxRequest(request, response, form);
|
||||
}
|
||||
else
|
||||
{
|
||||
form.erase(KEY_TYPE);
|
||||
handleForm(form);
|
||||
}
|
||||
}
|
||||
else
|
||||
handleForm(form);
|
||||
}
|
||||
handlePageRequest(request, response);
|
||||
}
|
||||
else
|
||||
handlePageRequest(request, response);
|
||||
{
|
||||
handleAjaxRequest(request, response, args);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user