svn cleanup
[anytun.git] / Sockets / HttpRequest.h
blob38290e42848f81cefb314e2fd5d81049057349c2
1 /**
2 ** \file HttpRequest.h
3 ** \date 2007-10-05
4 ** \author grymse@alhem.net
5 **/
6 /*
7 Copyright (C) 2007 Anders Hedstrom
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License
11 as published by the Free Software Foundation; either version 2
12 of the License, or (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #ifndef _SOCKETS_HttpRequest_H
24 #define _SOCKETS_HttpRequest_H
26 #include "HttpTransaction.h"
27 #include "HttpdCookies.h"
28 #include <memory>
29 #include "IFile.h"
31 #ifdef SOCKETS_NAMESPACE
32 namespace SOCKETS_NAMESPACE {
33 #endif
36 class HttpdForm;
37 class IFile;
39 class HttpRequest : public HttpTransaction
41 public:
42 HttpRequest();
43 HttpRequest(const HttpRequest& src);
44 ~HttpRequest();
46 /** Get, Post */
47 void SetHttpMethod(const std::string& value);
48 const std::string& HttpMethod() const;
50 /** HTTP/1.x */
51 void SetHttpVersion(const std::string& value);
52 const std::string& HttpVersion() const;
54 void SetUri(const std::string& value);
55 const std::string& Uri() const;
57 void SetRemoteAddr(const std::string& value);
58 const std::string& RemoteAddr() const;
60 void SetRemoteHost(const std::string& value);
61 const std::string& RemoteHost() const;
63 void SetServerName(const std::string& value);
64 const std::string& ServerName() const;
66 void SetServerPort(int value);
67 int ServerPort() const;
69 void SetIsSsl(bool value);
70 bool IsSsl() const;
72 /** Set / Read attribute value */
73 void SetAttribute(const std::string& key, const std::string& value);
74 void SetAttribute(const std::string& key, long value);
75 const std::string& Attribute(const std::string& key) const;
77 const std::map<std::string, std::string>& Attributes() const;
79 /** Cookies */
80 void AddCookie(const std::string& );
81 const std::map<std::string, std::string>& CookieMap() const { return m_cookie; }
83 /** Open file for body data */
84 void InitBody( size_t sz );
86 /** Write body data */
87 void Write( const char *buf, size_t sz );
89 /** No more writing */
90 void CloseBody();
92 void ParseBody();
94 const HttpdForm& Form() const;
95 const HttpdCookies& Cookies() const;
97 const IFile *BodyFile() const { return m_body_file.get(); }
99 void Reset();
101 private:
102 std::string m_method;
103 std::string m_protocol;
104 std::string m_req_uri;
105 std::string m_remote_addr;
106 std::string m_remote_host;
107 std::string m_server_name;
108 int m_server_port;
109 bool m_is_ssl;
110 std::map<std::string, std::string> m_attribute;
111 std::string m_null;
112 mutable std::auto_ptr<IFile> m_body_file;
113 mutable std::auto_ptr<HttpdForm> m_form;
114 HttpdCookies m_cookies;
115 std::map<std::string, std::string> m_cookie;
117 }; // end of class
120 #ifdef SOCKETS_NAMESPACE
121 } // namespace SOCKETS_NAMESPACE {
122 #endif
124 #endif // _SOCKETS_HttpRequest_H