pion  5.0.6
include/pion/http/types.hpp
00001 // ---------------------------------------------------------------------
00002 // pion:  a Boost C++ framework for building lightweight HTTP interfaces
00003 // ---------------------------------------------------------------------
00004 // Copyright (C) 2007-2014 Splunk Inc.  (https://github.com/splunk/pion)
00005 //
00006 // Distributed under the Boost Software License, Version 1.0.
00007 // See http://www.boost.org/LICENSE_1_0.txt
00008 //
00009 
00010 #ifndef __PION_HTTP_TYPES_HEADER__
00011 #define __PION_HTTP_TYPES_HEADER__
00012 
00013 #include <string>
00014 #include <pion/config.hpp>
00015 #include <pion/hash_map.hpp>
00016 
00017 
00018 namespace pion {    // begin namespace pion
00019 namespace http {    // begin namespace http
00020 
00021 
00025 struct PION_API types
00026 {
00028     virtual ~types() {}
00029     
00030     // generic strings used by HTTP
00031     static const std::string    STRING_EMPTY;
00032     static const std::string    STRING_CRLF;
00033     static const std::string    STRING_HTTP_VERSION;
00034     static const std::string    HEADER_NAME_VALUE_DELIMITER;
00035     static const std::string    COOKIE_NAME_VALUE_DELIMITER;
00036     
00037     // common HTTP header names
00038     static const std::string    HEADER_HOST;
00039     static const std::string    HEADER_COOKIE;
00040     static const std::string    HEADER_SET_COOKIE;
00041     static const std::string    HEADER_CONNECTION;
00042     static const std::string    HEADER_CONTENT_TYPE;
00043     static const std::string    HEADER_CONTENT_LENGTH;
00044     static const std::string    HEADER_CONTENT_LOCATION;
00045     static const std::string    HEADER_CONTENT_ENCODING;
00046     static const std::string    HEADER_CONTENT_DISPOSITION;
00047     static const std::string    HEADER_LAST_MODIFIED;
00048     static const std::string    HEADER_IF_MODIFIED_SINCE;
00049     static const std::string    HEADER_TRANSFER_ENCODING;
00050     static const std::string    HEADER_LOCATION;
00051     static const std::string    HEADER_AUTHORIZATION;
00052     static const std::string    HEADER_REFERER;
00053     static const std::string    HEADER_USER_AGENT;
00054     static const std::string    HEADER_X_FORWARDED_FOR;
00055     static const std::string    HEADER_CLIENT_IP;
00056 
00057     // common HTTP content types
00058     static const std::string    CONTENT_TYPE_HTML;
00059     static const std::string    CONTENT_TYPE_TEXT;
00060     static const std::string    CONTENT_TYPE_XML;
00061     static const std::string    CONTENT_TYPE_URLENCODED;
00062     static const std::string    CONTENT_TYPE_MULTIPART_FORM_DATA;
00063     
00064     // common HTTP request methods
00065     static const std::string    REQUEST_METHOD_HEAD;
00066     static const std::string    REQUEST_METHOD_GET;
00067     static const std::string    REQUEST_METHOD_PUT;
00068     static const std::string    REQUEST_METHOD_POST;
00069     static const std::string    REQUEST_METHOD_DELETE;
00070     
00071     // common HTTP response messages
00072     static const std::string    RESPONSE_MESSAGE_OK;
00073     static const std::string    RESPONSE_MESSAGE_CREATED;
00074     static const std::string    RESPONSE_MESSAGE_ACCEPTED;
00075     static const std::string    RESPONSE_MESSAGE_NO_CONTENT;
00076     static const std::string    RESPONSE_MESSAGE_FOUND;
00077     static const std::string    RESPONSE_MESSAGE_UNAUTHORIZED;
00078     static const std::string    RESPONSE_MESSAGE_FORBIDDEN;
00079     static const std::string    RESPONSE_MESSAGE_NOT_FOUND;
00080     static const std::string    RESPONSE_MESSAGE_METHOD_NOT_ALLOWED;
00081     static const std::string    RESPONSE_MESSAGE_NOT_MODIFIED;
00082     static const std::string    RESPONSE_MESSAGE_BAD_REQUEST;
00083     static const std::string    RESPONSE_MESSAGE_SERVER_ERROR;
00084     static const std::string    RESPONSE_MESSAGE_NOT_IMPLEMENTED;
00085     static const std::string    RESPONSE_MESSAGE_CONTINUE;
00086 
00087     // common HTTP response codes
00088     static const unsigned int   RESPONSE_CODE_OK;
00089     static const unsigned int   RESPONSE_CODE_CREATED;
00090     static const unsigned int   RESPONSE_CODE_ACCEPTED;
00091     static const unsigned int   RESPONSE_CODE_NO_CONTENT;
00092     static const unsigned int   RESPONSE_CODE_FOUND;
00093     static const unsigned int   RESPONSE_CODE_UNAUTHORIZED;
00094     static const unsigned int   RESPONSE_CODE_FORBIDDEN;
00095     static const unsigned int   RESPONSE_CODE_NOT_FOUND;
00096     static const unsigned int   RESPONSE_CODE_METHOD_NOT_ALLOWED;
00097     static const unsigned int   RESPONSE_CODE_NOT_MODIFIED;
00098     static const unsigned int   RESPONSE_CODE_BAD_REQUEST;
00099     static const unsigned int   RESPONSE_CODE_SERVER_ERROR;
00100     static const unsigned int   RESPONSE_CODE_NOT_IMPLEMENTED;
00101     static const unsigned int   RESPONSE_CODE_CONTINUE;
00102     
00103 
00105     static std::string get_date_string(const time_t t);
00106 
00108     static std::string make_query_string(const ihash_multimap& query_params);
00109     
00121     static std::string make_set_cookie_header(const std::string& name,
00122                                               const std::string& value,
00123                                               const std::string& path,
00124                                               const bool has_max_age = false,
00125                                               const unsigned long max_age = 0);     
00126 };
00127 
00128 
00129 }   // end namespace http
00130 }   // end namespace pion
00131 
00132 #endif