2013-09-06 14:44:01 -07:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
/*
|
|
|
|
|
This file is part of Beast: https://github.com/vinniefalco/Beast
|
|
|
|
|
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
|
|
|
|
|
|
|
|
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
|
purpose with or without fee is hereby granted, provided that the above
|
|
|
|
|
copyright notice and this permission notice appear in all copies.
|
|
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
|
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
|
*/
|
|
|
|
|
//==============================================================================
|
|
|
|
|
|
2015-01-29 12:48:39 -05:00
|
|
|
#ifndef BEAST_MODULE_ASIO_HTTPMESSAGE_H_INCLUDED
|
|
|
|
|
#define BEAST_MODULE_ASIO_HTTPMESSAGE_H_INCLUDED
|
2013-09-06 14:44:01 -07:00
|
|
|
|
2014-10-25 17:59:04 -07:00
|
|
|
#include <beast/module/asio/HTTPHeaders.h>
|
|
|
|
|
#include <beast/module/asio/HTTPVersion.h>
|
2014-03-24 07:21:19 -07:00
|
|
|
|
2014-05-29 11:59:36 -07:00
|
|
|
#include <beast/smart_ptr/SharedObject.h>
|
|
|
|
|
#include <beast/net/DynamicBuffer.h>
|
2014-06-03 14:48:34 -07:00
|
|
|
#include <beast/module/core/text/StringPairArray.h>
|
2014-03-20 18:08:54 -07:00
|
|
|
|
2014-03-07 20:06:12 -08:00
|
|
|
namespace beast {
|
|
|
|
|
|
2013-09-06 14:44:01 -07:00
|
|
|
/** A complete HTTP message.
|
|
|
|
|
|
|
|
|
|
This provides the information common to all HTTP messages, including
|
|
|
|
|
the version, content body, and headers.
|
|
|
|
|
Derived classes provide the request or response specific data.
|
|
|
|
|
|
|
|
|
|
Because a single HTTP message can be a fairly expensive object to
|
|
|
|
|
make copies of, this is a SharedObject.
|
|
|
|
|
|
|
|
|
|
@see HTTPRequest, HTTPResponse
|
|
|
|
|
*/
|
|
|
|
|
class HTTPMessage : public SharedObject
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
/** Construct the common HTTP message parts from values.
|
|
|
|
|
Ownership of the fields and body parameters are
|
|
|
|
|
transferred from the caller.
|
|
|
|
|
*/
|
|
|
|
|
HTTPMessage (HTTPVersion const& version_,
|
|
|
|
|
StringPairArray& fields,
|
2013-10-03 19:44:26 -07:00
|
|
|
DynamicBuffer& body);
|
2013-09-06 14:44:01 -07:00
|
|
|
|
|
|
|
|
/** Returns the HTTP version of this message. */
|
|
|
|
|
HTTPVersion const& version () const;
|
|
|
|
|
|
|
|
|
|
/** Returns the set of HTTP headers associated with this message. */
|
|
|
|
|
HTTPHeaders const& headers () const;
|
|
|
|
|
|
|
|
|
|
/** Returns the content-body. */
|
2013-10-03 19:44:26 -07:00
|
|
|
DynamicBuffer const& body () const;
|
2013-09-06 14:44:01 -07:00
|
|
|
|
2013-09-11 18:24:40 -07:00
|
|
|
/** Outputs all the HTTPMessage data excluding the body into a string. */
|
|
|
|
|
String toString () const;
|
2015-07-28 23:24:25 -04:00
|
|
|
|
2013-09-06 14:44:01 -07:00
|
|
|
private:
|
|
|
|
|
HTTPVersion m_version;
|
|
|
|
|
HTTPHeaders m_headers;
|
2013-10-03 19:44:26 -07:00
|
|
|
DynamicBuffer m_body;
|
2013-09-06 14:44:01 -07:00
|
|
|
};
|
|
|
|
|
|
2014-03-07 20:06:12 -08:00
|
|
|
}
|
|
|
|
|
|
2013-09-06 14:44:01 -07:00
|
|
|
#endif
|