Spinning Topp Logo BlackTopp Studios
inc
httpresponse.h
1 // © Copyright 2010 - 2016 BlackTopp Studios Inc.
2 /* This file is part of The Mezzanine Engine.
3 
4  The Mezzanine Engine is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  The Mezzanine Engine is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with The Mezzanine Engine. If not, see <http://www.gnu.org/licenses/>.
16 */
17 /* The original authors have included a copy of the license specified above in the
18  'Docs' folder. See 'gpl.txt'
19 */
20 /* We welcome the use of the Mezzanine engine to anyone, including companies who wish to
21  Build professional software and charge for their product.
22 
23  However there are some practical restrictions, so if your project involves
24  any of the following you should contact us and we will try to work something
25  out:
26  - DRM or Copy Protection of any kind(except Copyrights)
27  - Software Patents You Do Not Wish to Freely License
28  - Any Kind of Linking to Non-GPL licensed Works
29  - Are Currently In Violation of Another Copyright Holder's GPL License
30  - If You want to change our code and not add a few hundred MB of stuff to
31  your distribution
32 
33  These and other limitations could cause serious legal problems if you ignore
34  them, so it is best to simply contact us or the Free Software Foundation, if
35  you have any questions.
36 
37  Joseph Toppi - toppij@gmail.com
38  John Blackwood - makoenergy02@gmail.com
39 */
40 
41 #ifndef _networkhttpresponse_h
42 #define _networkhttpresponse_h
43 
44 #include "version.h"
45 #include "Network/networkenumerations.h"
46 #include "Network/httpmessage.h"
47 
48 namespace Mezzanine
49 {
50  namespace Network
51  {
52  ///////////////////////////////////////////////////////////////////////////////
53  /// @brief A response to an HTTPRequest generated by an HTTP server.
54  ///////////////////////////////////////
56  {
57  protected:
58  /// @internal
59  /// @brief The HTTP method to use for the response.
61  /// @internal
62  /// @brief The textual message delivered to explain the status code.
64 
65  /// @copydoc HTTPMessage::ParseHTTPHeader(StringIterator&,const StringIterator)
66  Boole ParseHTTPHeader(StringIterator& CurrIt, const StringIterator EndIt);
67  public:
68  /// @brief Class constructor.
69  HTTPResponse();
70  /// @brief String constructor.
71  /// @param ToDecompose The String to construct this response from.
72  HTTPResponse(const String& ToDecompose);
73  /// @brief Class destructor.
74  ~HTTPResponse();
75 
76  ///////////////////////////////////////////////////////////////////////////////
77  // Core Operations
78 
79  /// @copydoc HTTPMessage::Compose() const
80  String Compose() const;
81  /// @copydoc HTTPMessage::Decompose(const String&)
82  Boole Decompose(const String& Message);
83  /// @copydoc HTTPMessage::Decompose(const String&)
84  Boole Decompose(StringIterator& CurrIt, const StringIterator EndIt);
85 
86  ///////////////////////////////////////////////////////////////////////////////
87  // Utility
88 
89  /// @brief Sets the status code explaining the result of a HTTP request.
90  /// @param Code The HTTP status code representing the manner of response to a previous HTTP request.
91  void SetStatusCode(const Whole Code);
92  /// @brief Gets the status code explaining the result of a HTTP request.
93  /// @return Returns a HTTPStatusCode enum value explaining the result of a previous HTTP request.
94  Whole GetStatusCode() const;
95 
96  /// @brief Sets the textual description to explain the status code contained in the response.
97  /// @param Message A String to explain the provided status code.
98  void SetResponseDescription(const String& Message);
99  /// @brief Gets the textual description to explain the status code contained in the response.
100  /// @return Returns a String containing the description of the status code.
101  const String& GetResponseDescription() const;
102 
103  ///////////////////////////////////////////////////////////////////////////////
104  // Recommended Header Field Convenience Methods
105 
106  /// @brief Sets the Allow Header.
107  /// @remarks This header is required to be defined in a response when the server responds with "405 Method not allowed".
108  /// @param Allow A comma separated list of HTTP methods that are allowed to be performed on the on the resource located on the responding server.
109  void SetAllowHeader(const String& Allow);
110  /// @brief Gets the Allow Header.
111  /// @return Returns a String containing a comma separated list of supported HTTP methods allowed to be used on the specified resource, or blank if the field is not set.
112  const String& GetAllowHeader() const;
113  /// @brief Sets the Content-Encoding Header.
114  /// @remarks This header is required if any kind of encoding is performed on the message body of the response.
115  /// @param ContentEncoding A description of the encoding used on the message body if it were encoded/compressed.
116  void SetContentEncodingHeader(const String& ContentEncoding);
117  /// @brief Gets the Content-Encoding Header.
118  /// @return Returns a String containing a description of the encoding used on the message body if it were encoded/compressed, or blank if the field is not set.
119  const String& GetContentEncodingHeader() const;
120  /// @brief Sets the Date Header.
121  /// @remarks A server must provide a Date header if it is capable of providing a reasonable approximation of the actual time.
122  /// @param Date The time and date of when the server processed the request in UTC.
123  void SetDateHeader(const String& Date);
124  /// @brief Gets the Date Header.
125  /// @return Returns a String containing the time and date of when the server processed the request in UTC, or blank if the field is not set.
126  const String& GetDateHeader() const;
127  /// @brief Sets the Server Header.
128  /// @remarks An optional but widely used header field to describe what software is running on the server.
129  /// @param Server Information on the platform/server being used by the server.
130  void SetServerHeader(const String& Server);
131  /// @brief Gets the Server Header.
132  /// @return Returns a String containing information on the platform/server being used by the server, or blank if the field is not set.
133  const String& GetServerHeader() const;
134  };//HTTPResponse
135  }//Network
136 }//Mezzanine
137 
138 #endif
String::const_iterator StringIterator
Convenience typedef for String iterators.
Definition: httpmessage.h:77
A base class for HTTP text parsing classes.
Definition: httpmessage.h:73
String ResponseDescription
The textual message delivered to explain the status code.
Definition: httpresponse.h:63
bool Boole
Generally acts a single bit, true or false.
Definition: datatypes.h:173
A response to an HTTPRequest generated by an HTTP server.
Definition: httpresponse.h:55
#define MEZZ_LIB
Some platforms require special decorations to denote what is exported/imported in a share library...
Whole ResponseCode
The HTTP method to use for the response.
Definition: httpresponse.h:60
The bulk of the engine components go in this namspace.
Definition: actor.cpp:56
unsigned long Whole
Whole is an unsigned integer, it will be at least 32bits in size.
Definition: datatypes.h:151
std::string String
A datatype used to a series of characters.
Definition: datatypes.h:159