|
@@ -34,24 +34,24 @@ class WebRequest(object):
|
|
|
|
|
|
|
|
def respondHTTP(self,status,body):
|
|
def respondHTTP(self,status,body):
|
|
|
status = str(status)
|
|
status = str(status)
|
|
|
- msg = "HTTP/1.0 %s\r\nContent-Type: text/html\r\n\r\n%s" % (status,body)
|
|
|
|
|
- self.connection.SendThisResponse(msg)
|
|
|
|
|
|
|
+ msg = u"HTTP/1.0 %s\r\nContent-Type: text/html\r\n\r\n%s" % (status,body)
|
|
|
|
|
+ self.connection.SendThisResponse(encodedUtf8(msg))
|
|
|
|
|
|
|
|
def respond(self,body):
|
|
def respond(self,body):
|
|
|
self.respondHTTP("200 OK",body)
|
|
self.respondHTTP("200 OK",body)
|
|
|
|
|
|
|
|
def respondXML(self,body):
|
|
def respondXML(self,body):
|
|
|
- msg = "HTTP/1.0 200 OK\r\nContent-Type: text/xml\r\n\r\n%s" % body
|
|
|
|
|
- self.connection.SendThisResponse(msg)
|
|
|
|
|
|
|
+ msg = u"HTTP/1.0 200 OK\r\nContent-Type: text/xml\r\n\r\n%s" % body
|
|
|
|
|
+ self.connection.SendThisResponse(encodedUtf8(msg))
|
|
|
|
|
|
|
|
def respondCustom(self,contentType,body):
|
|
def respondCustom(self,contentType,body):
|
|
|
- msg = "HTTP/1.0 200 OK\r\nContent-Type: %s" % contentType
|
|
|
|
|
|
|
+ msg = u"HTTP/1.0 200 OK\r\nContent-Type: %s" % contentType
|
|
|
|
|
|
|
|
if contentType in ["text/css",]:
|
|
if contentType in ["text/css",]:
|
|
|
msg += "\nCache-Control: max-age=313977290\nExpires: Tue, 02 May 2017 04:08:44 GMT\n"
|
|
msg += "\nCache-Control: max-age=313977290\nExpires: Tue, 02 May 2017 04:08:44 GMT\n"
|
|
|
|
|
|
|
|
- msg += "\r\n\r\n%s" % (body)
|
|
|
|
|
- self.connection.SendThisResponse(msg)
|
|
|
|
|
|
|
+ msg += u"\r\n\r\n%s" % (body)
|
|
|
|
|
+ self.connection.SendThisResponse(encodedUtf8(msg))
|
|
|
|
|
|
|
|
def timeout(self):
|
|
def timeout(self):
|
|
|
resp = "<html><body>Error 504: Request timed out</body></html>\r\n"
|
|
resp = "<html><body>Error 504: Request timed out</body></html>\r\n"
|