source: XMLIO_V2/external/include/Poco/Net/HTTPRequest.h @ 80

Last change on this file since 80 was 80, checked in by ymipsl, 14 years ago

ajout lib externe

  • Property svn:eol-style set to native
File size: 5.1 KB
Line 
1//
2// HTTPRequest.h
3//
4// $Id: //poco/1.3/Net/include/Poco/Net/HTTPRequest.h#2 $
5//
6// Library: Net
7// Package: HTTP
8// Module:  HTTPRequest
9//
10// Definition of the HTTPRequest class.
11//
12// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
13// and Contributors.
14//
15// Permission is hereby granted, free of charge, to any person or organization
16// obtaining a copy of the software and accompanying documentation covered by
17// this license (the "Software") to use, reproduce, display, distribute,
18// execute, and transmit the Software, and to prepare derivative works of the
19// Software, and to permit third-parties to whom the Software is furnished to
20// do so, all subject to the following:
21//
22// The copyright notices in the Software and this entire statement, including
23// the above license grant, this restriction and the following disclaimer,
24// must be included in all copies of the Software, in whole or in part, and
25// all derivative works of the Software, unless such copies or derivative
26// works are solely in the form of machine-executable object code generated by
27// a source language processor.
28//
29// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
32// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
33// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
34// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
35// DEALINGS IN THE SOFTWARE.
36//
37
38
39#ifndef Net_HTTPRequest_INCLUDED
40#define Net_HTTPRequest_INCLUDED
41
42
43#include "Poco/Net/Net.h"
44#include "Poco/Net/HTTPMessage.h"
45
46
47namespace Poco {
48namespace Net {
49
50
51class Net_API HTTPRequest: public HTTPMessage
52        /// This class encapsulates an HTTP request
53        /// message.
54        ///
55        /// In addition to the properties common to
56        /// all HTTP messages, a HTTP request has
57        /// a method (e.g. GET, HEAD, POST, etc.) and
58        /// a request URI.
59{
60public:
61        HTTPRequest();
62                /// Creates a GET / HTTP/1.0 HTTP request.
63               
64        HTTPRequest(const std::string& version);
65                /// Creates a GET / HTTP/1.x request with
66                /// the given version (HTTP/1.0 or HTTP/1.1).
67               
68        HTTPRequest(const std::string& method, const std::string& uri);
69                /// Creates a HTTP/1.0 request with the given method and URI.
70
71        HTTPRequest(const std::string& method, const std::string& uri, const std::string& version);
72                /// Creates a HTTP request with the given method, URI and version.
73
74        virtual ~HTTPRequest();
75                /// Destroys the HTTPRequest.
76
77        void setMethod(const std::string& method);
78                /// Sets the method.
79
80        const std::string& getMethod() const;
81                /// Returns the method.
82
83        void setURI(const std::string& uri);
84                /// Sets the request URI.
85               
86        const std::string& getURI() const;
87                /// Returns the request URI.
88               
89        void setHost(const std::string& host);
90                /// Sets the value of the Host header field.
91               
92        void setHost(const std::string& host, Poco::UInt16 port);
93                /// Sets the value of the Host header field.
94               
95        const std::string& getHost() const;
96                /// Returns the value of the Host header field.
97                ///
98                /// Throws a NotFoundException if the request
99                /// does not have a Host header field.
100
101        void setCookies(const NameValueCollection& cookies);
102                /// Adds a Cookie header with the names and
103                /// values from cookies.
104               
105        void getCookies(NameValueCollection& cookies) const;
106                /// Fills cookies with the cookies extracted
107                /// from the Cookie headers in the request.
108
109        bool hasCredentials() const;
110                /// Returns true iff the request contains authentication
111                /// information in the form of an Authorization header.
112               
113        void getCredentials(std::string& scheme, std::string& authInfo) const;
114                /// Returns the authentication scheme and additional authentication
115                /// information contained in this request.
116                ///
117                /// Throws a NotAuthenticatedException if no authentication information
118                /// is contained in the request.
119               
120        void setCredentials(const std::string& scheme, const std::string& authInfo);
121                /// Sets the authentication scheme and information for
122                /// this request.
123
124        void write(std::ostream& ostr) const;
125                /// Writes the HTTP request to the given
126                /// output stream.
127
128        void read(std::istream& istr);
129                /// Reads the HTTP request from the
130                /// given input stream.
131               
132        static const std::string HTTP_GET;
133        static const std::string HTTP_HEAD;
134        static const std::string HTTP_PUT;
135        static const std::string HTTP_POST;
136        static const std::string HTTP_OPTIONS;
137        static const std::string HTTP_DELETE;
138        static const std::string HTTP_TRACE;
139        static const std::string HTTP_CONNECT;
140       
141        static const std::string HOST;
142        static const std::string COOKIE;
143        static const std::string AUTHORIZATION;
144
145private:
146        enum Limits
147        {
148                MAX_METHOD_LENGTH  = 32,
149                MAX_URI_LENGTH     = 4096,
150                MAX_VERSION_LENGTH = 8
151        };
152       
153        std::string _method;
154        std::string _uri;
155       
156        HTTPRequest(const HTTPRequest&);
157        HTTPRequest& operator = (const HTTPRequest&);
158};
159
160
161//
162// inlines
163//
164inline const std::string& HTTPRequest::getMethod() const
165{
166        return _method;
167}
168
169
170inline const std::string& HTTPRequest::getURI() const
171{
172        return _uri;
173}
174
175
176} } // namespace Poco::Net
177
178
179#endif // Net_HTTPRequest_INCLUDED
Note: See TracBrowser for help on using the repository browser.