-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathResponse.py
More file actions
21 lines (21 loc) · 858 Bytes
/
Response.py
File metadata and controls
21 lines (21 loc) · 858 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import http.cookies as Cookie
class Response:
def __init__(self,baseHttp,responseWriter=None,contentType='text/html'):
self.__responseWriter=responseWriter
self.__contentType=contentType
self.__baseHttp=baseHttp
self.__cookie=Cookie.SimpleCookie()
def addCookie(self,name,value):
self.__cookie[name]=value
def write(self,str,type="utf-8"):
self.__responseWriter.write(bytes(str,type))
def setHeader(self,name,value):
self.__baseHttp.send_header(name,value)
def setContentType(self,contentType='text/html'):
self.__contentType=contentType
#self.__baseHttp.send_header('Set-Cookie',self.__cookie.output(header=''))
self.__baseHttp.send_header('Content-type',contentType)
#self.__baseHttp.send_header('Set-Cookie',self.__cookie.output(header=''))
self.__baseHttp.end_headers()
def getContentType(self):
return self.__contentType