pion-net  4.0.9
HTTPTypes.hpp
1 // ------------------------------------------------------------------
2 // pion-net: a C++ framework for building lightweight HTTP interfaces
3 // ------------------------------------------------------------------
4 // Copyright (C) 2007-2011 Atomic Labs, Inc. (http://www.atomiclabs.com)
5 //
6 // Distributed under the Boost Software License, Version 1.0.
7 // See http://www.boost.org/LICENSE_1_0.txt
8 //
9 
10 #ifndef __PION_HTTPTYPES_HEADER__
11 #define __PION_HTTPTYPES_HEADER__
12 
13 #include <string>
14 #include <pion/PionConfig.hpp>
15 #include <pion/PionHashMap.hpp>
16 
17 
18 namespace pion { // begin namespace pion
19 namespace net { // begin namespace net (Pion Network Library)
20 
24 struct PION_NET_API HTTPTypes
25 {
27  virtual ~HTTPTypes() {}
28 
29  // generic strings used by HTTP
30  static const std::string STRING_EMPTY;
31  static const std::string STRING_CRLF;
32  static const std::string STRING_HTTP_VERSION;
33  static const std::string HEADER_NAME_VALUE_DELIMITER;
34 
35  // common HTTP header names
36  static const std::string HEADER_HOST;
37  static const std::string HEADER_COOKIE;
38  static const std::string HEADER_SET_COOKIE;
39  static const std::string HEADER_CONNECTION;
40  static const std::string HEADER_CONTENT_TYPE;
41  static const std::string HEADER_CONTENT_LENGTH;
42  static const std::string HEADER_CONTENT_LOCATION;
43  static const std::string HEADER_CONTENT_ENCODING;
44  static const std::string HEADER_LAST_MODIFIED;
45  static const std::string HEADER_IF_MODIFIED_SINCE;
46  static const std::string HEADER_TRANSFER_ENCODING;
47  static const std::string HEADER_LOCATION;
48  static const std::string HEADER_AUTHORIZATION;
49  static const std::string HEADER_REFERER;
50  static const std::string HEADER_USER_AGENT;
51  static const std::string HEADER_X_FORWARDED_FOR;
52  static const std::string HEADER_CLIENT_IP;
53 
54  // common HTTP content types
55  static const std::string CONTENT_TYPE_HTML;
56  static const std::string CONTENT_TYPE_TEXT;
57  static const std::string CONTENT_TYPE_XML;
58  static const std::string CONTENT_TYPE_URLENCODED;
59 
60  // common HTTP request methods
61  static const std::string REQUEST_METHOD_HEAD;
62  static const std::string REQUEST_METHOD_GET;
63  static const std::string REQUEST_METHOD_PUT;
64  static const std::string REQUEST_METHOD_POST;
65  static const std::string REQUEST_METHOD_DELETE;
66 
67  // common HTTP response messages
68  static const std::string RESPONSE_MESSAGE_OK;
69  static const std::string RESPONSE_MESSAGE_CREATED;
70  static const std::string RESPONSE_MESSAGE_ACCEPTED;
71  static const std::string RESPONSE_MESSAGE_NO_CONTENT;
72  static const std::string RESPONSE_MESSAGE_FOUND;
73  static const std::string RESPONSE_MESSAGE_UNAUTHORIZED;
74  static const std::string RESPONSE_MESSAGE_FORBIDDEN;
75  static const std::string RESPONSE_MESSAGE_NOT_FOUND;
76  static const std::string RESPONSE_MESSAGE_METHOD_NOT_ALLOWED;
77  static const std::string RESPONSE_MESSAGE_NOT_MODIFIED;
78  static const std::string RESPONSE_MESSAGE_BAD_REQUEST;
79  static const std::string RESPONSE_MESSAGE_SERVER_ERROR;
80  static const std::string RESPONSE_MESSAGE_NOT_IMPLEMENTED;
81  static const std::string RESPONSE_MESSAGE_CONTINUE;
82 
83  // common HTTP response codes
84  static const unsigned int RESPONSE_CODE_OK;
85  static const unsigned int RESPONSE_CODE_CREATED;
86  static const unsigned int RESPONSE_CODE_ACCEPTED;
87  static const unsigned int RESPONSE_CODE_NO_CONTENT;
88  static const unsigned int RESPONSE_CODE_FOUND;
89  static const unsigned int RESPONSE_CODE_UNAUTHORIZED;
90  static const unsigned int RESPONSE_CODE_FORBIDDEN;
91  static const unsigned int RESPONSE_CODE_NOT_FOUND;
92  static const unsigned int RESPONSE_CODE_METHOD_NOT_ALLOWED;
93  static const unsigned int RESPONSE_CODE_NOT_MODIFIED;
94  static const unsigned int RESPONSE_CODE_BAD_REQUEST;
95  static const unsigned int RESPONSE_CODE_SERVER_ERROR;
96  static const unsigned int RESPONSE_CODE_NOT_IMPLEMENTED;
97  static const unsigned int RESPONSE_CODE_CONTINUE;
98 
101 
104 
107 
108 
110  static std::string get_date_string(const time_t t);
111 
113  static std::string make_query_string(const QueryParams& query_params);
114 
126  static std::string make_set_cookie_header(const std::string& name,
127  const std::string& value,
128  const std::string& path,
129  const bool has_max_age = false,
130  const unsigned long max_age = 0);
131 };
132 
133 } // end namespace net
134 } // end namespace pion
135 
136 #endif
PION_HASH_MULTIMAP< std::string, std::string, CaseInsensitiveHash, CaseInsensitiveEqual > StringDictionary
data type for case-insensitive dictionary of strings
virtual ~HTTPTypes()
virtual destructor
Definition: HTTPTypes.hpp:27
StringDictionary Headers
data type for HTTP headers
Definition: HTTPTypes.hpp:100
StringDictionary QueryParams
data type for HTTP query parameters
Definition: HTTPTypes.hpp:106
StringDictionary CookieParams
data type for HTTP cookie parameters
Definition: HTTPTypes.hpp:103
the following enables use of the lock-free cache