From 2fb0ebb05b734a4e8eb12502bafc932651408b23 Mon Sep 17 00:00:00 2001
From: Benjamin Sergeant <bsergean@gmail.com>
Date: Thu, 26 Sep 2019 09:27:27 -0700
Subject: [PATCH] http server: in redirect mode, POST request are given a 200
 status code and an empty response

---
 docs/CHANGELOG.md |  2 +-
 ws/ws_httpd.cpp   | 14 ++++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index 71fcc86d..29c0367a 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file.
 
 ## [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
diff --git a/ws/ws_httpd.cpp b/ws/ws_httpd.cpp
index aad3cbba..52714116 100644
--- a/ws/ws_httpd.cpp
+++ b/ws/ws_httpd.cpp
@@ -31,7 +31,21 @@ namespace ix
                 [redirectUrl](
                     HttpRequestPtr request,
                     std::shared_ptr<ConnectionState> /*connectionState*/) -> HttpResponsePtr {
+
                     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;
 
                     return std::make_shared<HttpResponse>(