MXS-1220: Add support for X-HTTP-Method-Override
This header allows clients to override the request method to work around client library limitations.
This commit is contained in:
@ -159,10 +159,14 @@ The value of this header must be a date value in the
|
|||||||
#### X-HTTP-Method-Override
|
#### X-HTTP-Method-Override
|
||||||
|
|
||||||
Some clients only support GET and PUT requests. By providing the string value of
|
Some clients only support GET and PUT requests. By providing the string value of
|
||||||
the intended method in the `X-HTTP-Method-Override` header, a client can perform
|
the intended method in the `X-HTTP-Method-Override` header, a client can, for
|
||||||
a POST, PATCH or DELETE request with the PUT method
|
example, perform a POST, PATCH or DELETE request with the PUT method
|
||||||
(e.g. `X-HTTP-Method-Override: PATCH`).
|
(e.g. `X-HTTP-Method-Override: PATCH`).
|
||||||
|
|
||||||
|
If this header is defined in the request, the current method of the request is
|
||||||
|
replaced with the one in the header. The HTTP method must be in uppercase and it
|
||||||
|
must be one of the methods that the requested resource supports.
|
||||||
|
|
||||||
### Response Headers
|
### Response Headers
|
||||||
|
|
||||||
#### Allow
|
#### Allow
|
||||||
|
@ -20,7 +20,8 @@
|
|||||||
using std::string;
|
using std::string;
|
||||||
using std::deque;
|
using std::deque;
|
||||||
|
|
||||||
#define HTTP_HOST_HEADER "Host"
|
#define HTTP_HOST_HEADER "Host"
|
||||||
|
#define HTTP_METHOD_OVERRIDE "X-HTTP-Method-Override"
|
||||||
|
|
||||||
const std::string HttpRequest::HTTP_PREFIX = "http://";
|
const std::string HttpRequest::HTTP_PREFIX = "http://";
|
||||||
const std::string HttpRequest::HTTPS_PREFIX = "https://";
|
const std::string HttpRequest::HTTPS_PREFIX = "https://";
|
||||||
@ -95,6 +96,13 @@ HttpRequest::HttpRequest(struct MHD_Connection *connection, string url, string m
|
|||||||
m_hostname = mxs_admin_https_enabled() ? HttpRequest::HTTPS_PREFIX : HttpRequest::HTTP_PREFIX;
|
m_hostname = mxs_admin_https_enabled() ? HttpRequest::HTTPS_PREFIX : HttpRequest::HTTP_PREFIX;
|
||||||
m_hostname += get_header(HTTP_HOST_HEADER);
|
m_hostname += get_header(HTTP_HOST_HEADER);
|
||||||
|
|
||||||
|
string method_override = get_header(HTTP_METHOD_OVERRIDE);
|
||||||
|
|
||||||
|
if (method_override.length())
|
||||||
|
{
|
||||||
|
m_verb = method_override;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_hostname[m_hostname.size() - 1] != '/')
|
if (m_hostname[m_hostname.size() - 1] != '/')
|
||||||
{
|
{
|
||||||
m_hostname += "/";
|
m_hostname += "/";
|
||||||
|
Reference in New Issue
Block a user