3 //=============================================================================
9 //=============================================================================
12 #ifndef HTTP_REQUEST_H
13 #define HTTP_REQUEST_H
15 #include "ace/config-all.h"
17 #if !defined (ACE_LACKS_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
30 * @brief This parses the client request of an HTTP transaction.
35 /// Default construction.
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
,
56 /// HTTP request method
57 const char *method () const;
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
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
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
98 /// The length of the request data
101 /// The length of incoming content if any
102 int content_length ();
104 /// Current status of the incoming request
107 /// A string describing the state of the incoming request
108 const char *status_string ();
110 /// Dump the state of the request.
122 // Values for request type
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
);
165 int got_request_line () const;
168 int got_request_line_
;
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
];
197 #endif /* HTTP_REQUEST_H */