1 // ANNA - Anna is Not Nothingness Anymore
3 // (c) Copyright 2005-2014 Eduardo Ramos Testillano & Francisco Ruiz Rayo
5 // http://redmine.teslayout.com/projects/anna-suite
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions
11 // * Redistributions of source code must retain the above copyright
12 // notice, this list of conditions and the following disclaimer.
13 // * Redistributions in binary form must reproduce the above
14 // copyright notice, this list of conditions and the following disclaimer
15 // in the documentation and/or other materials provided with the
17 // * Neither the name of the copyright holder nor the names of its
18 // contributors may be used to endorse or promote products derived from
19 // this software without specific prior written permission.
21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 // Authors: eduardo.ramos.testillano@gmail.com
34 // cisco.tierra@gmail.com
37 #ifndef anna_http_Response_hpp
38 #define anna_http_Response_hpp
40 #include <anna/http/Message.hpp>
47 Clase que modela las respuestas HTTP segun la RFC 2616.
49 class Response : public Message {
55 Message(Message::Type::Response) { a_statusCode = 0; setStatusCode(200); }
58 Devuelve el codigo de estado contenido en la respuesta.
59 \return El codigo de estado contenido en la respuesta
61 int getStatusCode() const throw() { return a_statusCode; }
64 Devuelve el campo ReasePhrase contenido en la respuesta.
65 \return el campo ReasePhrase contenido en la respuesta.
67 const std::string& getReasonPhrase() const throw() { return a_reasonPhrase; }
70 Establece el codigo de retorno de la respuesta HTTP. Si es un codigo reconocido por la RFC 2616
71 tambien establece el ReasonPhrase por defecto.
73 Los codigos de respuesta reconocidos por la RFC 2616 son:
76 101: Switching Protocols
80 203: Non-Authoritative Information
85 301: Moved Permanently
90 307: Temporary Redirect
96 405: Method Not Allowed
98 407: Proxy Authentication Required
103 412: Precondition Failed
104 413: Request Entity Too Large
105 414: Request-URI Too Large
106 415: Unsupported Media Type
107 416: Requested range not satisfiable
108 417: Expectation Failed
109 500: Internal Server Error
112 503: Service Unavailable
113 504: Gateway Time-out
114 505: HTTP Version not supported
117 void setStatusCode(const int statusCode) throw();
120 Establece la frase asociada a la respuesta.
121 \param reasonPhrase Frase asociada a la respuesta.
123 void setReasonPhrase(const std::string& reasonPhrase) throw() { a_reasonPhrase = reasonPhrase; }
126 Establece la frase asociada a la respuesta.
127 \param reasonPhrase Frase asociada a la respuesta.
129 void setReasonPhrase(const char* reasonPhrase) throw() { a_reasonPhrase = reasonPhrase; }
132 Devuelve una cadena con toda la informacion relevante de este objeto.
133 \return una cadena con toda la informacion relevante de este objeto.
135 std::string asString() const throw();
139 std::string a_reasonPhrase;
141 std::string codeStartLine() const throw(anna::RuntimeException);