5eb454f0ce50dbd6eb03d556984f29122a55ef0d
[shibboleth/cpp-xmltooling.git] / xmltooling / io / HTTPRequest.h
1 /*
2  *  Copyright 2001-2010 Internet2
3  * 
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 /**
18  * @file xmltooling/io/HTTPRequest.h
19  * 
20  * Interface to HTTP requests.
21  */
22
23 #ifndef __xmltooling_httpreq_h__
24 #define __xmltooling_httpreq_h__
25
26 #include <xmltooling/io/GenericRequest.h>
27
28 #include <map>
29 #include <cstring>
30
31 namespace xmltooling {
32
33 #if defined (_MSC_VER)
34     #pragma warning( push )
35     #pragma warning( disable : 4251 )
36 #endif
37
38     /**
39      * Interface to HTTP requests.
40      * 
41      * <p>To supply information from the surrounding web server environment,
42      * a shim must be supplied in the form of this interface to adapt the
43      * library to different proprietary server APIs.
44      * 
45      * <p>This interface need not be threadsafe.
46      */
47     class XMLTOOL_API HTTPRequest : public GenericRequest {
48     protected:
49         HTTPRequest();
50     public:
51         virtual ~HTTPRequest();
52
53         bool isSecure() const;
54           
55         /**
56          * Returns the HTTP method of the request (GET, POST, etc.)
57          * 
58          * @return the HTTP method
59          */
60         virtual const char* getMethod() const=0;
61         
62         /**
63          * Returns the request URI.
64          * 
65          * @return the request URI
66          */
67         virtual const char* getRequestURI() const=0;
68         
69         /**
70          * Returns the complete request URL, including scheme, host, port, and URI.
71          * 
72          * @return the request URL
73          */
74         virtual const char* getRequestURL() const=0;
75
76         /**
77          * Returns the HTTP query string appened to the request. The query
78          * string is returned without any decoding applied, everything found
79          * after the ? delimiter. 
80          * 
81          * @return the query string
82          */
83         virtual const char* getQueryString() const=0;
84
85         /**
86          * Returns a request header value.
87          * 
88          * @param name  the name of the header to return
89          * @return the header's value, or an empty string
90          */
91         virtual std::string getHeader(const char* name) const=0;
92
93         /**
94          * Get a cookie value supplied by the client.
95          * 
96          * @param name  name of cookie
97          * @return  cookie value or nullptr
98          */
99         virtual const char* getCookie(const char* name) const;
100
101     private:
102         mutable std::map<std::string,std::string> m_cookieMap;
103     };
104
105 #if defined (_MSC_VER)
106     #pragma warning( pop )
107 #endif
108
109 };
110
111 #endif /* __xmltooling_httpreq_h__ */