~ubuntu-branches/ubuntu/lucid/znc/lucid-backports

« back to all changes in this revision

Viewing changes to .pc/02-inc-port-in-cookie.diff/HTTPSock.h

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2011-05-11 13:34:53 UTC
  • mfrom: (13.1.8 sid)
  • Revision ID: james.westby@ubuntu.com-20110511133453-334862gk6gh8dmwp
Tags: 0.092-3~lucid1
Automated backport upload; no source changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2004-2010  See the AUTHORS file for details.
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or modify it
 
5
 * under the terms of the GNU General Public License version 2 as published
 
6
 * by the Free Software Foundation.
 
7
 */
 
8
 
 
9
#ifndef _HTTPSOCK_H
 
10
#define _HTTPSOCK_H
 
11
 
 
12
#include "Socket.h"
 
13
 
 
14
class CModule;
 
15
 
 
16
class CHTTPSock : public CSocket {
 
17
public:
 
18
        CHTTPSock(CModule *pMod);
 
19
        CHTTPSock(CModule *pMod, const CString& sHostname, unsigned short uPort, int iTimeout = 60);
 
20
        virtual ~CHTTPSock();
 
21
 
 
22
        // Csocket derived members
 
23
        virtual void ReadData(const char* data, size_t len);
 
24
        virtual void ReadLine(const CString& sData);
 
25
        virtual void ReachedMaxBuffer();
 
26
        virtual void SockError(int iErrno);
 
27
        virtual void Timeout();
 
28
        virtual void Connected();
 
29
        virtual void Disconnected();
 
30
        virtual Csock* GetSockObj(const CString& sHost, unsigned short uPort) = 0;
 
31
        // !Csocket derived members
 
32
 
 
33
        // Hooks
 
34
        virtual bool ForceLogin();
 
35
        virtual bool OnLogin(const CString& sUser, const CString& sPass);
 
36
        virtual void OnPageRequest(const CString& sURI) = 0;
 
37
        virtual bool PrintFile(const CString& sFileName, CString sContentType = "");
 
38
        // !Hooks
 
39
 
 
40
        void CheckPost();
 
41
        bool SentHeader() const;
 
42
        bool PrintHeader(off_t uContentLength, const CString& sContentType = "", unsigned int uStatusId = 200, const CString& sStatusMsg = "OK");
 
43
        void AddHeader(const CString& sName, const CString& sValue);
 
44
        void SetContentType(const CString& sContentType);
 
45
 
 
46
        bool PrintNotFound();
 
47
        bool Redirect(const CString& sURL);
 
48
        CString GetErrorPage(unsigned int uStatusId, const CString& sStatusMsg, const CString& sMessage);
 
49
        bool PrintErrorPage(unsigned int uStatusId, const CString& sStatusMsg, const CString& sMessage);
 
50
        static void ParseParams(const CString& sParams, map<CString, VCString>& msvsParams);
 
51
        void ParseURI();
 
52
        void GetPage();
 
53
 
 
54
        // Cookies
 
55
        const MCString& GetRequestCookies() const;
 
56
        CString GetRequestCookie(const CString& sKey) const;
 
57
        bool SendCookie(const CString& sKey, const CString& sValue);
 
58
        // Cookies
 
59
 
 
60
        // Setters
 
61
        void SetDocRoot(const CString& s);
 
62
        void SetLoggedIn(bool b) { m_bLoggedIn = b; }
 
63
        // !Setters
 
64
 
 
65
        // Getters
 
66
        CString GetPath() const;
 
67
        bool IsLoggedIn() const { return m_bLoggedIn; }
 
68
        const CString& GetDocRoot() const;
 
69
        const CString& GetUser() const;
 
70
        const CString& GetPass() const;
 
71
        const CString& GetParamString() const;
 
72
        const CString& GetContentType() const;
 
73
        bool IsPost() const;
 
74
        // !Getters
 
75
 
 
76
        // Parameter access
 
77
        CString GetParam(const CString& sName, bool bPost = true, const CString& sFilter = "\r\n") const;
 
78
        CString GetRawParam(const CString& sName, bool bPost = true) const;
 
79
        bool HasParam(const CString& sName, bool bPost = true) const;
 
80
        const map<CString, VCString>& GetParams(bool bPost = true) const;
 
81
        unsigned int GetParamValues(const CString& sName, VCString& vsRet, bool bPost = true, const CString& sFilter = "\r\n") const;
 
82
        unsigned int GetParamValues(const CString& sName, set<CString>& ssRet, bool bPost = true, const CString& sFilter = "\r\n") const;
 
83
        // !Parameter access
 
84
private:
 
85
        static CString GetRawParam(const CString& sName, const map<CString, VCString>& msvsParams);
 
86
        static CString GetParam(const CString& sName, const map<CString, VCString>& msvsParams, const CString& sFilter);
 
87
        static unsigned int GetParamValues(const CString& sName, VCString& vsRet, const map<CString, VCString>& msvsParams, const CString& sFilter);
 
88
        static unsigned int GetParamValues(const CString& sName, set<CString>& ssRet, const map<CString, VCString>& msvsParams, const CString& sFilter);
 
89
 
 
90
protected:
 
91
        void PrintPage(const CString& sPage);
 
92
        void Init();
 
93
 
 
94
        bool                     m_bSentHeader;
 
95
        bool                     m_bGotHeader;
 
96
        bool                     m_bLoggedIn;
 
97
        bool                     m_bPost;
 
98
        bool                     m_bDone;
 
99
        unsigned long            m_uPostLen;
 
100
        CString                  m_sPostData;
 
101
        CString                  m_sURI;
 
102
        CString                  m_sUser;
 
103
        CString                  m_sPass;
 
104
        CString                  m_sContentType;
 
105
        CString                  m_sDocRoot;
 
106
        map<CString, VCString>   m_msvsPOSTParams;
 
107
        map<CString, VCString>   m_msvsGETParams;
 
108
        MCString                 m_msHeaders;
 
109
        bool                     m_bHTTP10Client;
 
110
        CString                  m_sIfNoneMatch;
 
111
        MCString                 m_msRequestCookies;
 
112
        MCString                 m_msResponseCookies;
 
113
};
 
114
 
 
115
#endif // !_HTTPSOCK_H