Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / ACE / apps / JAWS / server / HTTP_Request.h
blobd3bc789e237447a25cc1f80e84fb16887e73354d
1 /* -*- c++ -*- */
3 //=============================================================================
4 /**
5 * @file HTTP_Request.h
7 * @author James Hu
8 */
9 //=============================================================================
12 #ifndef HTTP_REQUEST_H
13 #define HTTP_REQUEST_H
15 #include "ace/config-all.h"
17 #if !defined (ACE_LACKS_PRAGMA_ONCE)
18 # pragma once
19 #endif /* ACE_LACKS_PRAGMA_ONCE */
21 #include "Parse_Headers.h"
23 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
24 class ACE_Message_Block;
25 ACE_END_VERSIONED_NAMESPACE_DECL
27 /**
28 * @class HTTP_Request
30 * @brief This parses the client request of an HTTP transaction.
32 class HTTP_Request
34 public:
35 /// Default construction.
36 HTTP_Request ();
38 /// Destructor.
39 ~HTTP_Request ();
41 /// parse an incoming request
42 int parse_request (ACE_Message_Block &mb);
44 /// the first line of a request is the request line, which is of the
45 /// form: METHOD URI VERSION.
46 void parse_request_line (char *const request_line);
48 /// Initialize the request object. This will parse the buffer and
49 /// prepare for the accessors.
50 int init (char *const buffer,
51 int buflen);
53 public:
54 // = The Accessors.
56 /// HTTP request method
57 const char *method () const;
59 /// HTTP request uri
60 const char *uri () const;
62 /// HTTP request version
63 const char *version () const;
65 /// The HTTP request uri translated into a server filename path
66 const char *path () const;
68 /// TRUE of the request is a cgi request
69 int cgi () const;
71 /// The arguments to the cgi request
72 const char *cgi_args () const;
74 /// The environment variables passed to the CGI request
75 const char **cgi_env () const;
77 /// The cgi request query string
78 const char *query_string () const;
80 /// The cgi request path information
81 const char *path_info () const;
83 /// The type of the HTTP request
84 int type () const;
86 /// The headers that were parsed from the request
87 const Headers &headers () const;
89 /// Header strings stored
90 const char *header_strings (int index) const;
92 /// Values associated with the header strings
93 const char *header_values (int index) const;
95 /// The buffer into which request data is read
96 char *data ();
98 /// The length of the request data
99 int data_length ();
101 /// The length of incoming content if any
102 int content_length ();
104 /// Current status of the incoming request
105 int status ();
107 /// A string describing the state of the incoming request
108 const char *status_string ();
110 /// Dump the state of the request.
111 void dump ();
113 enum
115 NO_TYPE = -1,
116 GET = 0,
117 HEAD,
118 POST,
119 PUT,
120 NUM_METHOD_STRINGS
122 // Values for request type
124 enum
126 DATE = 0,
127 PRAGMA,
128 AUTHORIZATION,
129 FROM,
130 IF_MODIFIED_SINCE,
131 REFERRER,
132 USER_AGENT,
133 ALLOW,
134 CONTENT_ENCODING,
135 CONTENT_LENGTH,
136 CONTENT_TYPE,
137 EXPIRES,
138 LAST_MODIFIED,
139 NUM_HEADER_STRINGS
141 // Header strings
143 private:
144 // = Private Accessors which can set values
145 const char *method (const char *method_string);
146 const char *uri (char *uri_string);
147 const char *version (const char *version_string);
148 const char *path (const char *uri_string);
150 /// determine if the given URI is a CGI program.
151 int cgi (char *uri_string);
153 /// determine if the given URI resides in a cgi-bin directory
154 int cgi_in_path (char *uri_string, char *&extra_path_info);
156 /// determine if the given URI contains a cgi extension
157 int cgi_in_extension (char *uri_string, char *&extra_path_info);
159 /// set the arguments and environment for the cgi program
160 void cgi_args_and_env (char *&extra_path_info);
162 int type (const char *type_string);
164 private:
165 int got_request_line () const;
167 private:
168 int got_request_line_;
169 Headers headers_;
171 char *method_;
172 char *uri_;
173 char *version_;
174 char *path_;
176 int cgi_;
177 char **cgi_env_;
178 char *cgi_args_;
180 char *query_string_;
181 char *path_info_;
183 const char * const *const header_strings_;
184 static const char *const static_header_strings_[NUM_HEADER_STRINGS];
186 const char * const *const method_strings_;
187 static const char *const static_method_strings_[NUM_METHOD_STRINGS];
189 char *data_;
190 int datalen_;
191 int content_length_;
192 char *filename_;
193 int status_;
194 int type_;
197 #endif /* HTTP_REQUEST_H */