-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathhttp.h
More file actions
119 lines (91 loc) · 2.96 KB
/
http.h
File metadata and controls
119 lines (91 loc) · 2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*****************************************************************************
File: http.h
Date: 21Apr06
Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
Gmail: garbagecat10
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*****************************************************************************/
#ifndef __HttpPersonality__H_
#define __HttpPersonality__H_
/**********************
class HttpConnection_t
**********************/
class HttpConnection_t
{
public:
HttpConnection_t();
virtual ~HttpConnection_t();
void ConsumeData (const char*, int);
virtual void SendData (const char*, int);
virtual void CloseConnection (bool after_writing);
virtual void ProcessRequest (const char *method,
const char *cookie,
const char *ifnonematch,
const char *content_type,
const char *query_string,
const char *path_info,
const char *request_uri,
const char *protocol,
int postlength,
const char *postdata,
const char* hdrblock,
int hdrblksize);
virtual void ReceivePostData(const char *data, int len);
virtual void SetNoEnvironmentStrings() {bSetEnvironmentStrings = false;}
virtual void SetDontAccumulatePost() {bAccumulatePost = false;}
virtual int GetMaxContentLength();
virtual void SetMaxContentLength(int len);
private:
enum {
BaseState,
PreheaderState,
HeaderState,
ReadingContentState,
DispatchState,
EndState
} ProtocolState;
enum {
MaxLeadingBlanks = 12,
MaxHeaderLineLength = 8 * 1024,
MaxContentLength = 20 * 1024 * 1024,
HeaderBlockSize = 16 * 1024
};
int nLeadingBlanks;
char HeaderLine [MaxHeaderLineLength];
int HeaderLinePos;
char HeaderBlock [HeaderBlockSize];
int HeaderBlockPos;
int ContentLength;
int ContentLengthLimit;
int ContentPos;
char *_Content;
bool bSetEnvironmentStrings;
bool bAccumulatePost;
bool bRequestSeen;
bool bContentLengthSeen;
const char *RequestMethod;
std::string Cookie;
std::string IfNoneMatch;
std::string ContentType;
std::string PathInfo;
std::string RequestUri;
std::string QueryString;
std::string Protocol;
private:
bool _InterpretHeaderLine (const char*);
bool _InterpretRequest (const char*);
bool _DetectVerbAndSetEnvString (const char*, int);
void _SendError (int);
void _SendError (int, const char*);
};
#endif // __HttpPersonality__H_