示例#1
0
 def handle_http_app(self, method, path, headers, body, lg):
     """
         Handle a request to the built-in app.
     """
     if self.pathod_handler.server.noweb:
         crafted = self.pathod_handler.make_http_error_response(
             "Access Denied")
         language.serve(crafted, self.pathod_handler.wfile,
                        self.pathod_handler.settings)
         return None, dict(type="error",
                           msg="Access denied: web interface disabled")
     lg("app: %s %s" % (method, path))
     req = wsgi.Request("http", method, path, b"HTTP/1.1", headers, body)
     flow = wsgi.Flow(self.pathod_handler.address, req)
     sn = self.pathod_handler.connection.getsockname()
     a = wsgi.WSGIAdaptor(self.pathod_handler.server.app, sn[0],
                          self.pathod_handler.server.address.port,
                          version.NAMEVERSION)
     a.serve(flow, self.pathod_handler.wfile)
     return self.pathod_handler.handle_http_request, None
def tflow():
    h = odict.ODictCaseless()
    h["test"] = ["value"]
    req = wsgi.Request("http", "GET", "/", h, "")
    return wsgi.Flow(("127.0.0.1", 8888), req)
示例#3
0
            except language.ParseException, v:
                self.info("Parse error: %s" % v.msg)
                crafted = language.make_error_response(
                    "Parse Error",
                    "Error parsing response spec: %s\n" % v.msg + v.marked())
            again, retlog["response"] = self.serve_crafted(crafted)
            return again, retlog
        elif self.server.noweb:
            crafted = language.make_error_response("Access Denied")
            language.serve(crafted, self.wfile, self.server.request_settings)
            return False, dict(type="error",
                               msg="Access denied: web interface disabled")
        else:
            self.info("app: %s %s" % (method, path))
            req = wsgi.Request("http", method, path, headers, content)
            flow = wsgi.Flow(self.address, req)
            sn = self.connection.getsockname()
            a = wsgi.WSGIAdaptor(self.server.app, sn[0],
                                 self.server.address.port, version.NAMEVERSION)
            a.serve(flow, self.wfile)
            return True, None

    def _log_bytes(self, header, data, hexdump):
        s = []
        if hexdump:
            s.append("%s (hex dump):" % header)
            for line in netlib.utils.hexdump(data):
                s.append("\t%s %s %s" % line)
        else:
            s.append("%s (unprintables escaped):" % header)
            s.append(netlib.utils.cleanBin(data))
示例#4
0
def tflow():
    headers = Headers(test=b"value")
    req = wsgi.Request("http", "GET", "/", "HTTP/1.1", headers, "")
    return wsgi.Flow(("127.0.0.1", 8888), req)