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