add raw_head to http_request

This commit is contained in:
Peter Thorson committed 2014-12-16 06:24:29 -05:00
1 parent 9dd99ead25
commit 867b323af0
2 files changed
+14 -8

No files matched your search

+10 -7
View File
@@ -138,6 +138,16 @@ inline std::string request::raw() const {
return ret.str();
}
inline std::string request::raw_head() const {
// TODO: validation. Make sure all required fields have been set?
std::stringstream ret;
ret << m_method << " " << m_uri << " " << get_version() << "\r\n";
ret << raw_headers() << "\r\n";
return ret.str();
}
inline void request::set_method(std::string const & method) {
if (std::find_if(method.begin(),method.end(),is_not_token_char) != method.end()) {
throw exception("Invalid method token.",status_code::bad_request);
@@ -146,13 +156,6 @@ inline void request::set_method(std::string const & method) {
m_method = method;
}
/// Set HTTP body
/**
* Sets the body of the HTTP object and fills in the appropriate content length
* header
*
* @param value The value to set the body to.
*/
inline void request::set_uri(std::string const & uri) {
// TODO: validation?
m_uri = uri;
+4 -1
View File
@@ -83,8 +83,11 @@ public:
return m_ready;
}
/// Returns the full raw request
/// Returns the full raw request (including the body)
std::string raw() const;
/// Returns the raw request headers only (similar to an HTTP HEAD request)
std::string raw_head() const;
/// Set the HTTP method. Must be a valid HTTP token
void set_method(std::string const & method);