Ejemplo n.º 1
0
def test_unparse_url():
    assert utils.unparse_url("http", "foo.com", 99, "") == "http://foo.com:99"
    assert utils.unparse_url("http", "foo.com", 80,
                             "/bar") == "http://foo.com/bar"
    assert utils.unparse_url("https", "foo.com", 80,
                             "") == "https://foo.com:80"
    assert utils.unparse_url("https", "foo.com", 443, "") == "https://foo.com"
Ejemplo n.º 2
0
 def url(self):
     """
     The URL string, constructed from the request's URL components
     """
     if self.first_line_format == "authority":
         return "%s:%d" % (self.host, self.port)
     return utils.unparse_url(self.scheme, self.host, self.port, self.path)
Ejemplo n.º 3
0
 def pretty_url(self):
     """
     Like :py:attr:`url`, but using :py:attr:`pretty_host` instead of :py:attr:`host`.
     """
     if self.first_line_format == "authority":
         return "%s:%d" % (self.pretty_host, self.port)
     return utils.unparse_url(self.scheme, self.pretty_host, self.port, self.path)
Ejemplo n.º 4
0
 def pretty_url(self):
     """
     Like :py:attr:`url`, but using :py:attr:`pretty_host` instead of :py:attr:`host`.
     """
     if self.first_line_format == "authority":
         return "%s:%d" % (self.pretty_host, self.port)
     return utils.unparse_url(self.scheme, self.pretty_host, self.port, self.path)
Ejemplo n.º 5
0
 def pretty_url(self, hostheader):
     if self.form_out == "authority":  # upstream proxy mode
         return "%s:%s" % (self.pretty_host(hostheader), self.port)
     return utils.unparse_url(self.scheme,
                              self.pretty_host(hostheader),
                              self.port,
                              self.path).encode('ascii')
Ejemplo n.º 6
0
 def url(self):
     """
     The URL string, constructed from the request's URL components
     """
     if self.first_line_format == "authority":
         return "%s:%d" % (self.host, self.port)
     return utils.unparse_url(self.scheme, self.host, self.port, self.path)
Ejemplo n.º 7
0
 def url(self):
     """
         Returns a URL string, constructed from the Request's URL components.
     """
     return utils.unparse_url(self.scheme,
                              self.host,
                              self.port,
                              self.path).encode('ascii')
Ejemplo n.º 8
0
    def get_url(self, hostheader=False):
        """
            Returns a URL string, constructed from the Request's URL components.

            If hostheader is True, we use the value specified in the request
            Host header to construct the URL.
        """
        return utils.unparse_url(self.get_scheme(), self.get_host(hostheader),
                                 self.get_port(), self.path).encode('ascii')
Ejemplo n.º 9
0
    def get_url(self, hostheader=False):
        """
            Returns a URL string, constructed from the Request's URL components.

            If hostheader is True, we use the value specified in the request
            Host header to construct the URL.
        """
        return utils.unparse_url(self.get_scheme(),
                                 self.get_host(hostheader),
                                 self.get_port(),
                                 self.path).encode('ascii')
Ejemplo n.º 10
0
    def get_url(self, hostheader=False):
        """
            Returns a URL string, constructed from the Request's URL components.

            If hostheader is True, we use the value specified in the request
            Host header to construct the URL.
        """
        if self.form_out == "authority":  # upstream proxy mode
            return "%s:%s" % (self.get_host(hostheader), self.get_port())
        return utils.unparse_url(self.get_scheme(), self.get_host(hostheader),
                                 self.get_port(), self.path).encode('ascii')
Ejemplo n.º 11
0
    def get_url(self, hostheader=False):
        """
            Returns a URL string, constructed from the Request's URL components.

            If hostheader is True, we use the value specified in the request
            Host header to construct the URL.
        """
        if self.form_out == "authority":  # upstream proxy mode
            return "%s:%s" % (self.get_host(hostheader), self.get_port())
        return utils.unparse_url(self.get_scheme(),
                                 self.get_host(hostheader),
                                 self.get_port(),
                                 self.path).encode('ascii')
Ejemplo n.º 12
0
    def get_status(self):
        r = []

        if self.master.setheaders.count():
            r.append("[")
            r.append(("heading_key", "H"))
            r.append("eaders]")
        if self.master.replacehooks.count():
            r.append("[")
            r.append(("heading_key", "R"))
            r.append("eplacing]")
        if self.master.client_playback:
            r.append("[")
            r.append(("heading_key", "cplayback"))
            r.append(":%s to go]" % self.master.client_playback.count())
        if self.master.server_playback:
            r.append("[")
            r.append(("heading_key", "splayback"))
            if self.master.nopop:
                r.append(":%s in file]" % self.master.server_playback.count())
            else:
                r.append(":%s to go]" % self.master.server_playback.count())
        if self.master.get_ignore_filter():
            r.append("[")
            r.append(("heading_key", "I"))
            r.append("gnore:%d]" % len(self.master.get_ignore_filter()))
        if self.master.get_tcp_filter():
            r.append("[")
            r.append(("heading_key", "T"))
            r.append("CP:%d]" % len(self.master.get_tcp_filter()))
        if self.master.state.intercept_txt:
            r.append("[")
            r.append(("heading_key", "i"))
            r.append(":%s]" % self.master.state.intercept_txt)
        if self.master.state.limit_txt:
            r.append("[")
            r.append(("heading_key", "l"))
            r.append(":%s]" % self.master.state.limit_txt)
        if self.master.stickycookie_txt:
            r.append("[")
            r.append(("heading_key", "t"))
            r.append(":%s]" % self.master.stickycookie_txt)
        if self.master.stickyauth_txt:
            r.append("[")
            r.append(("heading_key", "u"))
            r.append(":%s]" % self.master.stickyauth_txt)
        if self.master.state.default_body_view.name != "Auto":
            r.append("[")
            r.append(("heading_key", "M"))
            r.append(":%s]" % self.master.state.default_body_view.name)

        opts = []
        if self.master.anticache:
            opts.append("anticache")
        if self.master.anticomp:
            opts.append("anticomp")
        if self.master.showhost:
            opts.append("showhost")
        if not self.master.refresh_server_playback:
            opts.append("norefresh")
        if self.master.killextra:
            opts.append("killextra")
        if self.master.server.config.no_upstream_cert:
            opts.append("no-upstream-cert")
        if self.master.state.follow_focus:
            opts.append("following")
        if self.master.stream_large_bodies:
            opts.append("stream:%s" % netlib.utils.pretty_size(
                self.master.stream_large_bodies.max_size))

        if opts:
            r.append("[%s]" % (":".join(opts)))

        if self.master.server.config.mode in ["reverse", "upstream"]:
            dst = self.master.server.config.mode.dst
            scheme = "https" if dst[0] else "http"
            if dst[1] != dst[0]:
                scheme += "2https" if dst[1] else "http"
            r.append("[dest:%s]" % utils.unparse_url(scheme, *dst[2:]))
        if self.master.scripts:
            r.append("[")
            r.append(("heading_key", "s"))
            r.append("cripts:%s]" % len(self.master.scripts))
        # r.append("[lt:%0.3f]"%self.master.looptime)

        if self.master.stream:
            r.append("[W:%s]" % self.master.stream_path)

        return r
Ejemplo n.º 13
0
 def pretty_url(self, hostheader):
     if self.form_out == "authority":  # upstream proxy mode
         return "%s:%s" % (self.pretty_host(hostheader), self.port)
     return utils.unparse_url(self.scheme, self.pretty_host(hostheader),
                              self.port, self.path).encode('ascii')
Ejemplo n.º 14
0
def test_unparse_url():
    assert utils.unparse_url(b"http", b"foo.com", 99, b"") == b"http://foo.com:99"
    assert utils.unparse_url(b"http", b"foo.com", 80, b"/bar") == b"http://foo.com/bar"
    assert utils.unparse_url(b"https", b"foo.com", 80, b"") == b"https://foo.com:80"
    assert utils.unparse_url(b"https", b"foo.com", 443, b"") == b"https://foo.com"
Ejemplo n.º 15
0
 def url(self):
     """
         Returns a URL string, constructed from the Request's URL components.
     """
     return utils.unparse_url(self.scheme, self.host, self.port,
                              self.path).encode('ascii')
Ejemplo n.º 16
0
 def url(self):
     """
     The URL string, constructed from the request's URL components
     """
     return utils.unparse_url(self.scheme, self.host, self.port, self.path)
Ejemplo n.º 17
0
def test_unparse_url():
    assert utils.unparse_url("http", "foo.com", 99, "") == "http://foo.com:99"
    assert utils.unparse_url("http", "foo.com", 80, "") == "http://foo.com"
    assert utils.unparse_url("https", "foo.com", 80, "") == "https://foo.com:80"
    assert utils.unparse_url("https", "foo.com", 443, "") == "https://foo.com"
Ejemplo n.º 18
0
    def get_status(self):
        r = []

        if self.master.setheaders.count():
            r.append("[")
            r.append(("heading_key", "H"))
            r.append("eaders]")
        if self.master.replacehooks.count():
            r.append("[")
            r.append(("heading_key", "R"))
            r.append("eplacing]")
        if self.master.client_playback:
            r.append("[")
            r.append(("heading_key", "cplayback"))
            r.append(":%s to go]"%self.master.client_playback.count())
        if self.master.server_playback:
            r.append("[")
            r.append(("heading_key", "splayback"))
            if self.master.nopop:
                r.append(":%s in file]"%self.master.server_playback.count())
            else:
                r.append(":%s to go]"%self.master.server_playback.count())
        if self.master.get_ignore_filter():
            r.append("[")
            r.append(("heading_key", "I"))
            r.append("gnore:%d]" % len(self.master.get_ignore_filter()))
        if self.master.get_tcp_filter():
            r.append("[")
            r.append(("heading_key", "T"))
            r.append("CP:%d]" % len(self.master.get_tcp_filter()))
        if self.master.state.intercept_txt:
            r.append("[")
            r.append(("heading_key", "i"))
            r.append(":%s]"%self.master.state.intercept_txt)
        if self.master.state.limit_txt:
            r.append("[")
            r.append(("heading_key", "l"))
            r.append(":%s]"%self.master.state.limit_txt)
        if self.master.stickycookie_txt:
            r.append("[")
            r.append(("heading_key", "t"))
            r.append(":%s]"%self.master.stickycookie_txt)
        if self.master.stickyauth_txt:
            r.append("[")
            r.append(("heading_key", "u"))
            r.append(":%s]"%self.master.stickyauth_txt)
        if self.master.state.default_body_view.name != "Auto":
            r.append("[")
            r.append(("heading_key", "M"))
            r.append(":%s]"%self.master.state.default_body_view.name)

        opts = []
        if self.master.anticache:
            opts.append("anticache")
        if self.master.anticomp:
            opts.append("anticomp")
        if self.master.showhost:
            opts.append("showhost")
        if not self.master.refresh_server_playback:
            opts.append("norefresh")
        if self.master.killextra:
            opts.append("killextra")
        if self.master.server.config.no_upstream_cert:
            opts.append("no-upstream-cert")
        if self.master.state.follow_focus:
            opts.append("following")
        if self.master.stream_large_bodies:
            opts.append(
                "stream:%s" % netlib.utils.pretty_size(
                    self.master.stream_large_bodies.max_size
                )
            )

        if opts:
            r.append("[%s]"%(":".join(opts)))

        if self.master.server.config.mode in ["reverse", "upstream"]:
            dst = self.master.server.config.mode.dst
            scheme = "https" if dst[0] else "http"
            if dst[1] != dst[0]:
                scheme += "2https" if dst[1] else "http"
            r.append("[dest:%s]"%utils.unparse_url(scheme, *dst[2:]))
        if self.master.scripts:
            r.append("[")
            r.append(("heading_key", "s"))
            r.append("cripts:%s]"%len(self.master.scripts))
        # r.append("[lt:%0.3f]"%self.master.looptime)

        if self.master.stream:
            r.append("[W:%s]"%self.master.stream_path)

        return r
Ejemplo n.º 19
0
 def url(self):
     """
     The URL string, constructed from the request's URL components
     """
     return utils.unparse_url(self.scheme, self.host, self.port, self.path)