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.
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 * @file xmltooling/io/HTTPRequest.h
24 * Interface to HTTP requests.
27 #ifndef __xmltooling_httpreq_h__
28 #define __xmltooling_httpreq_h__
30 #include <xmltooling/io/GenericRequest.h>
32 namespace xmltooling {
34 #if defined (_MSC_VER)
35 #pragma warning( push )
36 #pragma warning( disable : 4251 )
40 * Interface to HTTP requests.
42 * <p>To supply information from the surrounding web server environment,
43 * a shim must be supplied in the form of this interface to adapt the
44 * library to different proprietary server APIs.
46 * <p>This interface need not be threadsafe.
48 class XMLTOOL_API HTTPRequest : public GenericRequest {
52 virtual ~HTTPRequest();
54 bool isSecure() const;
55 bool isDefaultPort() const;
56 std::string getLanguageRange() const;
59 * Returns the HTTP method of the request (GET, POST, etc.)
61 * @return the HTTP method
63 virtual const char* getMethod() const=0;
66 * Returns the request URI.
68 * @return the request URI
70 virtual const char* getRequestURI() const=0;
73 * Returns the complete request URL, including scheme, host, port, and URI.
75 * @return the request URL
77 virtual const char* getRequestURL() const=0;
80 * Returns the HTTP query string appened to the request. The query
81 * string is returned without any decoding applied, everything found
82 * after the ? delimiter.
84 * @return the query string
86 virtual const char* getQueryString() const=0;
89 * Returns a request header value.
91 * @param name the name of the header to return
92 * @return the header's value, or an empty string
94 virtual std::string getHeader(const char* name) const=0;
97 * Get a cookie value supplied by the client.
99 * @param name name of cookie
100 * @return cookie value or nullptr
102 virtual const char* getCookie(const char* name) const;
105 * Gets all the cookies supplied by the client.
107 * @return a map of cookie name/value pairs
109 virtual const std::map<std::string,std::string>& getCookies() const;
112 mutable std::map<std::string,std::string> m_cookieMap;
115 #if defined (_MSC_VER)
116 #pragma warning( pop )
121 #endif /* __xmltooling_httpreq_h__ */