-
Notifications
You must be signed in to change notification settings - Fork 0
/
fakeecb.py
38 lines (26 loc) · 983 Bytes
/
fakeecb.py
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
from StringIO import StringIO
class FakeECB:
def __init__(self):
self._stdout = StringIO()
self.AvailableBytes = 0
self.vars = {
"REQUEST_METHOD":"GET",
"SCRIPT_NAME":"/",
"PATH_INFO":"/",
"QUERY_STRING":"",
"CONTENT_TYPE":"",
"CONTENT_LENGTH":"0",
"SERVER_NAME":"localhost",
"SERVER_PORT":"80",
"SERVER_PROTOCOL":"HTTP/1.0",
"ALL_HTTP":""}
def WriteClient(self, s):
self._stdout.write(s)
write = WriteClient
def close(self):
print str(id(self)) +" close()"
def GetServerVariable(self, cgivar):
return self.vars[cgivar]
def SendResponseHeaders(self, status, headers, ka):
self._stdout.write(status + "\r\n")
self._stdout.write(headers)