MXS-1220: Take the resource handler into use

The resource handler system is now usable but it doesn't perform anything
useful. Although, this will allows it to be tested for correctness.

Minor fixes to HttpResponse output and renaming of functions.
This commit is contained in:
Markus Mäkelä
2017-04-17 10:36:33 +03:00
committed by Markus Mäkelä
parent 8b1c0cd1a1
commit 900bf2db5a
6 changed files with 46 additions and 38 deletions

View File

@ -264,7 +264,7 @@ static inline const char* http_code_to_string(enum http_code code)
*
* @return The RFC 1123 compliant date
*/
static inline string get_http_date()
static inline string http_get_date()
{
time_t now = time(NULL);
struct tm tm;

View File

@ -18,6 +18,7 @@
#include <map>
#include <string>
#include <tr1/memory>
#include <cstdint>
#include <maxscale/jansson.hh>
#include <maxscale/utils.hh>
@ -132,24 +133,37 @@ public:
}
/**
* @brief Get request resource
* @brief Get complete request URI
*
* @return The request resource
* @return The complete request URI
*/
const string& get_resource() const
const string& get_uri() const
{
return m_resource;
}
/**
* @brief Get request resource parts
* @brief Get URI part
*
* @return The request resource split into parts
* @param idx Zero indexed part number in URI
*
* @return The request URI part or empty string if no part was found
*/
const deque<string>& get_resource_parts() const
const string uri_part(uint32_t idx) const
{
return m_resource_parts;
return m_resource_parts.size() > idx ? m_resource_parts[idx] : "";
}
/**
* @brief Return how many parts are in the URI
*
* @return Number of URI parts
*/
size_t uri_part_count() const
{
return m_resource_parts.size();
}
private:
HttpRequest();
HttpRequest(const HttpRequest&);

View File

@ -39,7 +39,7 @@ public:
* @param response Response body
* @param code HTTP return code
*/
HttpResponse(string response = "", enum http_code code = HTTP_200_OK);
HttpResponse(enum http_code code = HTTP_200_OK, string response = "");
~HttpResponse();
@ -59,10 +59,7 @@ public:
string get_response() const;
private:
HttpResponse(const HttpResponse&);
HttpResponse& operator = (const HttpResponse&);
string m_body; /**< Message body */
map<string, string> m_headers; /**< Message headers */
http_code m_code; /**< The HTTP code for the response */
enum http_code m_code; /**< The HTTP code for the response */
};