except: # This should only happen if the module is buggy
# internal error, report as HTTP server error
self.hr.send_response(500)
+ self.hr.add_cookies()
self.hr.end_headers()
else:
# got a valid JSONRPC response
self.hr.send_response(200)
self.hr.send_header("Content-type", "text/x-json")
self.hr.send_header("Content-length", str(len(response)))
+ self.hr.add_cookies()
self.hr.end_headers()
self.hr.wfile.write(response)
response = 'No such page'
self.hr.send_header("Content-type", "text/plain")
self.hr.send_header("Content-length", str(len(response)))
+ self.hr.add_cookies()
self.hr.end_headers()
self.hr.wfile.write(response)
# shut down the connection
try:
req = cjson.decode(data)
method = req['method']
- params = req['params']
+ params = req['params'] or ()
id = req['id']
if dispatch_method is not None:
def messageReceived(self, msg):
if _debug: print 'messageReceived cmd=', msg.command, msg.path
ch = msg.headers.getheaders("Cookie")
+ ch += msg.headers.getheaders("cookie")
print "messageReceived cookieheaders=", '; '.join(ch)
res = []
for c in ch:
c = c.split(";")
+ if len(c) == 0:
+ continue
c = map(strip, c)
+ c = filter(lambda x: x, c)
res += c
has_sess = False
msg.response_cookies = SimpleCookie()
for c in res:
- print "found cookie", str(c)
+ print "found cookie", repr(c)
name, value = c.split("=")
msg.response_cookies[name] = value
- msg.response_cookies[name]['path'] = "/"
- msg.response_cookies[name]['domain'] = self.remote[0]
+ #msg.response_cookies[name]['path'] = "/"
+ #msg.response_cookies[name]['domain'] = self.remote[0]
#msg.response_cookies[name]['expires'] = 'None'
- msg.response_cookies[name]['version'] = 0
+ #msg.response_cookies[name]['version'] = 0
if name == "session":
has_sess = True
if not has_sess:
msg.response_cookies['session'] = uuid.uuid4().hex
#msg.response_cookies['session']['expires'] = 'None'
- msg.response_cookies['session']['path'] = '/'
- msg.response_cookies['session']['domain'] = self.remote[0]
- msg.response_cookies['session']['version'] = 0
+ #msg.response_cookies['session']['path'] = '/'
+ #msg.response_cookies['session']['domain'] = self.remote[0]
+ #msg.response_cookies['session']['version'] = 0
if msg.headers.has_key('content-length'):
max_chunk_size = 10*1024*1024