Example #1
0
 def do_POST(self):
     self.request_init()
     if self.path == '/RPC2':
         host = self.client_address[0]
         addr = [int(b) for b in host.split('.')]
         addr = (addr[0] << 24) | (addr[1] << 16) | (addr[2] << 8) | addr[3]
         if self.server.add_post_host(addr):
             print "error"
             return self.send_error(409, "Concurrent API alls not allowed")
         try:
             return DocXMLRPCRequestHandler.do_POST(self)
         finally:
             self.server.del_post_host(addr)
     try:
         fname = "post_" + self.path[1:].replace('-', '_')
         if hasattr(self, fname):
             fun = getattr(self, fname)
             data = self.rfile.read(int(self.headers["content-length"]))
             fields = dict([
                 urllib.unquote_plus(x).split('=') for x in data.split('&')
             ])
             f = fun(**fields)
             if f:
                 try:
                     self.copyfile(f, self.wfile)
                 finally:
                     f.close()
         else:
             return self.shutdown(404)
     except Exception, e:
         self.log_error("POST action %s failed: %s" % (self.path, e))
         self.send_error(500)
Example #2
0
 def do_POST(self):
     self.request_init()
     if self.path == '/RPC2':
         host = self.client_address[0]
         addr = [int(b) for b in host.split('.')]
         addr = (addr[0] << 24) | (addr[1] << 16) | (addr[2] << 8) | addr[3]
         if self.server.add_post_host(addr):
             print "error"
             return self.send_error(409, "Concurrent API alls not allowed")
         try:
             return DocXMLRPCRequestHandler.do_POST(self)
         finally:
             self.server.del_post_host(addr)
     try:
         fname = "post_" + self.path[1:].replace('-', '_')
         if hasattr(self, fname):
             fun = getattr(self, fname)
             data = self.rfile.read(int(self.headers["content-length"]))
             fields = dict([urllib.unquote_plus(x).split('=') for x in data.split('&')])
             f = fun(**fields)
             if f:
                 try:
                     self.copyfile(f, self.wfile)
                 finally:
                     f.close()
         else:
             return self.shutdown(404)
     except Exception, e:
         self.log_error("POST action %s failed: %s" % (self.path, e))
         self.send_error(500)
 def parse_request(myself):
     # first, call the original implementation which returns
     # True if all OK so far
     if DocXMLRPCRequestHandler.parse_request(myself):
         # next we authenticate
         if self.authenticate(myself.headers):
             return True
         else:
             # if authentication fails, tell the client
             myself.send_error(401, 'Authentication failed')
     return False
 def parse_request(myself):
     # first, call the original implementation which returns
     # True if all OK so far
     if DocXMLRPCRequestHandler.parse_request(myself):
         # next we authenticate
         if self.authenticate(myself.headers):
             return True
         else:
             # if authentication fails, tell the client
             myself.send_error(401, 'Authentication failed')
     return False
Example #5
0
 def end_headers(self):
    self.send_header("Access-Control-Allow-Origin", "*")
    DocXMLRPCRequestHandler.end_headers(self)
Example #6
0
 def do_GET(self):
     self.request_init()
     if self.path == '/RPC2':
         return DocXMLRPCRequestHandler.do_GET(self)
     return SimpleHTTPRequestHandler.do_GET(self)
Example #7
0
 def end_headers(self):
     self.send_header("Access-Control-Allow-Origin", "*")
     DocXMLRPCRequestHandler.end_headers(self)
Example #8
0
 def do_GET(self):
     self.request_init()
     if self.path == '/RPC2':
         return DocXMLRPCRequestHandler.do_GET(self)
     return SimpleHTTPRequestHandler.do_GET(self)