http server: in redirect mode, POST request are given a 200 status code and an empty response
This commit is contained in:
parent
7495c9ebb8
commit
2fb0ebb05b
@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file.
|
|||||||
|
|
||||||
## [6.2.8] - 2019-09-26
|
## [6.2.8] - 2019-09-26
|
||||||
|
|
||||||
- Http server: add options to ws https to redirect all requests to a given url.
|
- Http server: add options to ws https to redirect all requests to a given url. POST requests will get a 200 and an empty response.
|
||||||
|
|
||||||
```
|
```
|
||||||
ws httpd -L --redirect_url https://www.google.com
|
ws httpd -L --redirect_url https://www.google.com
|
||||||
|
@ -31,7 +31,21 @@ namespace ix
|
|||||||
[redirectUrl](
|
[redirectUrl](
|
||||||
HttpRequestPtr request,
|
HttpRequestPtr request,
|
||||||
std::shared_ptr<ConnectionState> /*connectionState*/) -> HttpResponsePtr {
|
std::shared_ptr<ConnectionState> /*connectionState*/) -> HttpResponsePtr {
|
||||||
|
|
||||||
WebSocketHttpHeaders headers;
|
WebSocketHttpHeaders headers;
|
||||||
|
|
||||||
|
// Log request
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << request->method << " " << request->headers["User-Agent"] << " "
|
||||||
|
<< request->uri;
|
||||||
|
spdlog::info(ss.str());
|
||||||
|
|
||||||
|
if (request->method == "POST")
|
||||||
|
{
|
||||||
|
return std::make_shared<HttpResponse>(
|
||||||
|
200, "OK", HttpErrorCode::Ok, headers, std::string());
|
||||||
|
}
|
||||||
|
|
||||||
headers["Location"] = redirectUrl;
|
headers["Location"] = redirectUrl;
|
||||||
|
|
||||||
return std::make_shared<HttpResponse>(
|
return std::make_shared<HttpResponse>(
|
||||||
|
Loading…
Reference in New Issue
Block a user