.. index:: pair: class; EE::Network::Http::Response .. _doxid-class_e_e_1_1_network_1_1_http_1_1_response: class EE::Network::Http::Response ================================= .. toctree:: :hidden: enum_EE_Network_Http_Response_Status.rst Overview ~~~~~~~~ Define a HTTP response. :ref:`More...` .. ref-code-block:: cpp :class: doxyrest-overview-code-block #include class Response { public: // typedefs typedef std::map :target:`FieldTable`; // enums enum :ref:`Status`; // methods static const char* :ref:`statusToString`(const :ref:`Status`& status); static :ref:`Status` :ref:`intAsStatus`(const int& value); static Response :ref:`createFakeResponse`(const :ref:`FieldTable`& fields, :ref:`Status`& status, const std::string& body, unsigned int majorVersion = 1, unsigned int minorVersion = 1); :ref:`FieldTable` :target:`getHeaders`(); const std::string& :ref:`getField`(const std::string& field) const; bool :ref:`hasField`(const std::string& field) const; :ref:`Status` :ref:`getStatus`() const; const char* :ref:`getStatusDescription`() const; unsigned int :ref:`getMajorHttpVersion`() const; unsigned int :ref:`getMinorHttpVersion`() const; const std::string& :ref:`getBody`() const; }; .. _details-class_e_e_1_1_network_1_1_http_1_1_response: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ Define a HTTP response. Methods ------- .. index:: pair: function; statusToString .. _doxid-class_e_e_1_1_network_1_1_http_1_1_response_1a3b2435d36c8f2b59e47cef9fb3e679ad: .. ref-code-block:: cpp :class: doxyrest-title-code-block static const char* statusToString(const :ref:`Status`& status) .. rubric:: Returns: The status string .. index:: pair: function; intAsStatus .. _doxid-class_e_e_1_1_network_1_1_http_1_1_response_1a8e022f3ff9bc548a871291af238a6714: .. ref-code-block:: cpp :class: doxyrest-title-code-block static :ref:`Status` intAsStatus(const int& value) .. rubric:: Returns: True if the value is a valid Status .. index:: pair: function; createFakeResponse .. _doxid-class_e_e_1_1_network_1_1_http_1_1_response_1a1456270022121d7af9a189d3eb53e360: .. ref-code-block:: cpp :class: doxyrest-title-code-block static Response createFakeResponse(const :ref:`FieldTable`& fields, :ref:`Status`& status, const std::string& body, unsigned int majorVersion = 1, unsigned int minorVersion = 1) Creates a faked response. Useful for testing. .. index:: pair: function; getField .. _doxid-class_e_e_1_1_network_1_1_http_1_1_response_1a85c05efb50bf09846e233b93f988f478: .. ref-code-block:: cpp :class: doxyrest-title-code-block const std::string& getField(const std::string& field) const Get the value of a field If the field *field* is not found in the response header, the empty string is returned. This function uses case-insensitive comparisons. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - field - Name of the field to get .. rubric:: Returns: Value of the field, or empty string if not found .. index:: pair: function; hasField .. _doxid-class_e_e_1_1_network_1_1_http_1_1_response_1a976693f5e801e12beaf07cc117f49f6a: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool hasField(const std::string& field) const .. rubric:: Returns: If the field is found in the response headers. .. index:: pair: function; getStatus .. _doxid-class_e_e_1_1_network_1_1_http_1_1_response_1aa7c00010ac89374463341b986aff979f: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`Status` getStatus() const Get the response status code The status code should be the first thing to be checked after receiving a response, it defines whether it is a success, a failure or anything else (see the Status enumeration). .. rubric:: Returns: Status code of the response .. index:: pair: function; getStatusDescription .. _doxid-class_e_e_1_1_network_1_1_http_1_1_response_1aa4813efb3926f54796788c0146bf2ca9: .. ref-code-block:: cpp :class: doxyrest-title-code-block const char* getStatusDescription() const Get the response status description. .. index:: pair: function; getMajorHttpVersion .. _doxid-class_e_e_1_1_network_1_1_http_1_1_response_1a02c1ad6ffef130efc3a473172e2f25de: .. ref-code-block:: cpp :class: doxyrest-title-code-block unsigned int getMajorHttpVersion() const Get the major HTTP version number of the response. .. rubric:: Returns: Major HTTP version number .. rubric:: See also: GetMinorHttpVersion .. index:: pair: function; getMinorHttpVersion .. _doxid-class_e_e_1_1_network_1_1_http_1_1_response_1a908e2dbdbb565ea9811fe905e5238fd5: .. ref-code-block:: cpp :class: doxyrest-title-code-block unsigned int getMinorHttpVersion() const Get the minor HTTP version number of the response. .. rubric:: Returns: Minor HTTP version number .. rubric:: See also: GetMajorHttpVersion .. index:: pair: function; getBody .. _doxid-class_e_e_1_1_network_1_1_http_1_1_response_1a1a13921c82500c702662a5eebc95e65d: .. ref-code-block:: cpp :class: doxyrest-title-code-block const std::string& getBody() const Get the body of the response The body of a response may contain: * the requested page (for GET requests) * a response from the server (for POST requests) * nothing (for HEAD requests) * an error message (in case of an error) .. rubric:: Returns: The response body