I have created a listener application using Latest Casablanca SDK. This is the source code.
for GET request
for GET request
listener.support(methods::GET, [](http_request req)
{
HKEY hKey;
LONG lRes = RegOpenKeyExW(HKEY_CURRENT_USER, L"SOFTWARE\\StrikeForce", 0, KEY_READ, &hKey);
bool bExistsAndSuccess (lRes == ERROR_SUCCESS);
bool bDoesNotExistsSpecifically (lRes == ERROR_FILE_NOT_FOUND);
std::wstring strValueOfBinDir;
GetStringRegKey(hKey, L"Encryption", strValueOfBinDir, L"1");
GIDSdkWriteXML();
http_response response (status_codes::OK);
response.headers().add(U("Access-Control-Allow-Origin"), U("*"));
//response.set_body(strValueOfBinDir, U("text/html"));
response.set_body(L"Welcome to StrikeForce", U("text/html"));
req.set_request_uri(L"requestpath");
req.reply(response);
});
For PUT requestlistener.support(methods::PUT,[](http_request req)
{
std::cout << "Serving PUT" << std::endl;
req.reply(status_codes::OK, U("<html><body><h1>It works!</h1>(Casablanca, that is a POST Request.)</body></html>"),
U("text/html"));
});
for POST requestlistener.support(methods::POST,[](http_request req)
{
std::cout << "Serving POST" << std::endl;
req.extract_string(true).then([req](utility::string_t body)
{
std::wcout << body << std::endl;
//req.reply(status_codes::OK, U("<html><body>Received.</body></html>"), U("text/html"));
});
});
The GET requst is send by browser plugins and from a web service, that is running remotely. Is there a way, I can use conditional statement, to determine, that if GET request is called from browser plugin, a different response should come and in case of web service, a different response should come?