Merge pull request #2216 from jwillemsen/jwi-cxxversionchecks
[ACE_TAO.git] / ACE / protocols / ace / INet / HTTP_Request.h
blobad423b6a3b0806d3c87297d4b9e66cf4155c68da
1 /**
2 * @file HTTP_Request.h
4 * @author Martin Corino <mcorino@remedy.nl>
5 */
7 #ifndef ACE_HTTP_REQUEST_H
8 #define ACE_HTTP_REQUEST_H
10 #include /**/ "ace/pre.h"
12 #include /**/ "ace/config-all.h"
14 #if !defined (ACE_LACKS_PRAGMA_ONCE)
15 # pragma once
16 #endif /* ACE_LACKS_PRAGMA_ONCE */
18 #include "ace/Containers_T.h"
19 #include "ace/INet/INet_Export.h"
20 #include "ace/INet/Request.h"
21 #include "ace/INet/HTTP_Header.h"
23 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
25 namespace ACE
27 namespace HTTP
29 class ACE_INET_Export Request
30 : public ACE::INet::Request, public Header
32 public:
33 /// Constructor; creates a GET / HTTP/1.0 HTTP request.
34 Request();
36 /// Constructor; creates a GET request with given version.
37 Request(const ACE_CString& version);
39 /// Constructor; creates a HTTP/1.0 request with given method and URI.
40 Request(const ACE_CString& method, const ACE_CString& uri);
42 /// Constructor; creates an HTTP request with given method, URI and version.
43 Request(const ACE_CString& method, const ACE_CString& uri, const ACE_CString& version);
45 /// Destructor
46 virtual ~Request();
48 /// Reset the request object
49 void reset ();
51 void reset (const ACE_CString& version);
53 void reset (const ACE_CString& method, const ACE_CString& uri);
55 void reset (const ACE_CString& method, const ACE_CString& uri, const ACE_CString& version);
57 /// Set the method.
58 void set_method(const ACE_CString& method);
60 /// Return the method.
61 const ACE_CString& get_method() const;
63 /// Set the request URI.
64 void set_URI(const ACE_CString& uri);
66 /// Return the request URI.
67 const ACE_CString& get_URI() const;
69 /// Set the Host header field.
70 void set_host(const ACE_CString& host);
72 void set_host(const ACE_CString& host, u_short port);
74 /// Returns true if Host header field has been set.
75 bool has_host () const;
77 /// Returns the value of the Host header field.
78 ACE_CString get_host() const;
80 /// Adds a Cookie header.
81 void add_cookie(const ACE_CString & cookie);
83 /// Get cookies from Cookie header(s).
84 void get_cookies(ACE_Array<ACE_CString> & cookies) const;
86 /// Returns true if the request contains authentication
87 /// information in the form of an Authorization header.
88 bool has_credentials() const;
90 /// Returns the authentication scheme and authentication information
91 void get_credentials(ACE_CString& scheme, ACE_CString& auth_info) const;
93 /// Set the authentication scheme and information
94 void set_credentials(const ACE_CString& scheme, const ACE_CString& auth_info);
96 /// Writes the HTTP request to the given stream
97 void write(std::ostream& str) const;
99 /// Reads the HTTP request from the
100 /// given stream.
101 bool read(std::istream& str);
103 static const ACE_CString HTTP_GET;
104 static const ACE_CString HTTP_HEAD;
105 static const ACE_CString HTTP_PUT;
106 static const ACE_CString HTTP_POST;
107 static const ACE_CString HTTP_OPTIONS;
108 static const ACE_CString HTTP_DELETE;
109 static const ACE_CString HTTP_TRACE;
110 static const ACE_CString HTTP_CONNECT;
112 static const ACE_CString HOST;
113 static const ACE_CString COOKIE;
114 static const ACE_CString AUTHORIZATION;
116 private:
117 enum Limits
119 MAX_METHOD_LENGTH = 32,
120 MAX_URI_LENGTH = 4096,
121 MAX_VERSION_LENGTH = 8
124 ACE_CString method_;
125 ACE_CString uri_;
130 ACE_END_VERSIONED_NAMESPACE_DECL
132 #if defined (__ACE_INLINE__)
133 #include "ace/INet/HTTP_Request.inl"
134 #endif
136 #include /**/ "ace/post.h"
137 #endif /* ACE_HTTP_REQUEST_H */