pion  5.0.6
types.hpp
1 // ---------------------------------------------------------------------
2 // pion: a Boost C++ framework for building lightweight HTTP interfaces
3 // ---------------------------------------------------------------------
4 // Copyright (C) 2007-2014 Splunk Inc. (https://github.com/splunk/pion)
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_HTTP_TYPES_HEADER__
11 #define __PION_HTTP_TYPES_HEADER__
12 
13 #include <string>
14 #include <pion/config.hpp>
15 #include <pion/hash_map.hpp>
16 
17 
18 namespace pion { // begin namespace pion
19 namespace http { // begin namespace http
20 
21 
25 struct PION_API types
26 {
28  virtual ~types() {}
29 
30  // generic strings used by HTTP
31  static const std::string STRING_EMPTY;
32  static const std::string STRING_CRLF;
33  static const std::string STRING_HTTP_VERSION;
34  static const std::string HEADER_NAME_VALUE_DELIMITER;
35  static const std::string COOKIE_NAME_VALUE_DELIMITER;
36 
37  // common HTTP header names
38  static const std::string HEADER_HOST;
39  static const std::string HEADER_COOKIE;
40  static const std::string HEADER_SET_COOKIE;
41  static const std::string HEADER_CONNECTION;
42  static const std::string HEADER_CONTENT_TYPE;
43  static const std::string HEADER_CONTENT_LENGTH;
44  static const std::string HEADER_CONTENT_LOCATION;
45  static const std::string HEADER_CONTENT_ENCODING;
46  static const std::string HEADER_CONTENT_DISPOSITION;
47  static const std::string HEADER_LAST_MODIFIED;
48  static const std::string HEADER_IF_MODIFIED_SINCE;
49  static const std::string HEADER_TRANSFER_ENCODING;
50  static const std::string HEADER_LOCATION;
51  static const std::string HEADER_AUTHORIZATION;
52  static const std::string HEADER_REFERER;
53  static const std::string HEADER_USER_AGENT;
54  static const std::string HEADER_X_FORWARDED_FOR;
55  static const std::string HEADER_CLIENT_IP;
56 
57  // common HTTP content types
58  static const std::string CONTENT_TYPE_HTML;
59  static const std::string CONTENT_TYPE_TEXT;
60  static const std::string CONTENT_TYPE_XML;
61  static const std::string CONTENT_TYPE_URLENCODED;
62  static const std::string CONTENT_TYPE_MULTIPART_FORM_DATA;
63 
64  // common HTTP request methods
65  static const std::string REQUEST_METHOD_HEAD;
66  static const std::string REQUEST_METHOD_GET;
67  static const std::string REQUEST_METHOD_PUT;
68  static const std::string REQUEST_METHOD_POST;
69  static const std::string REQUEST_METHOD_DELETE;
70 
71  // common HTTP response messages
72  static const std::string RESPONSE_MESSAGE_OK;
73  static const std::string RESPONSE_MESSAGE_CREATED;
74  static const std::string RESPONSE_MESSAGE_ACCEPTED;
75  static const std::string RESPONSE_MESSAGE_NO_CONTENT;
76  static const std::string RESPONSE_MESSAGE_FOUND;
77  static const std::string RESPONSE_MESSAGE_UNAUTHORIZED;
78  static const std::string RESPONSE_MESSAGE_FORBIDDEN;
79  static const std::string RESPONSE_MESSAGE_NOT_FOUND;
80  static const std::string RESPONSE_MESSAGE_METHOD_NOT_ALLOWED;
81  static const std::string RESPONSE_MESSAGE_NOT_MODIFIED;
82  static const std::string RESPONSE_MESSAGE_BAD_REQUEST;
83  static const std::string RESPONSE_MESSAGE_SERVER_ERROR;
84  static const std::string RESPONSE_MESSAGE_NOT_IMPLEMENTED;
85  static const std::string RESPONSE_MESSAGE_CONTINUE;
86 
87  // common HTTP response codes
88  static const unsigned int RESPONSE_CODE_OK;
89  static const unsigned int RESPONSE_CODE_CREATED;
90  static const unsigned int RESPONSE_CODE_ACCEPTED;
91  static const unsigned int RESPONSE_CODE_NO_CONTENT;
92  static const unsigned int RESPONSE_CODE_FOUND;
93  static const unsigned int RESPONSE_CODE_UNAUTHORIZED;
94  static const unsigned int RESPONSE_CODE_FORBIDDEN;
95  static const unsigned int RESPONSE_CODE_NOT_FOUND;
96  static const unsigned int RESPONSE_CODE_METHOD_NOT_ALLOWED;
97  static const unsigned int RESPONSE_CODE_NOT_MODIFIED;
98  static const unsigned int RESPONSE_CODE_BAD_REQUEST;
99  static const unsigned int RESPONSE_CODE_SERVER_ERROR;
100  static const unsigned int RESPONSE_CODE_NOT_IMPLEMENTED;
101  static const unsigned int RESPONSE_CODE_CONTINUE;
102 
103 
105  static std::string get_date_string(const time_t t);
106 
108  static std::string make_query_string(const ihash_multimap& query_params);
109 
121  static std::string make_set_cookie_header(const std::string& name,
122  const std::string& value,
123  const std::string& path,
124  const bool has_max_age = false,
125  const unsigned long max_age = 0);
126 };
127 
128 
129 } // end namespace http
130 } // end namespace pion
131 
132 #endif
virtual ~types()
virtual destructor
Definition: types.hpp:28