Exemple #1
0
    def test_get_proxy_information_with_proxy_over_https(self):
        """Show that the request path and method are returned for HTTPS reqs.

        Using HTTPS over a proxy changes the method used and the request path.
        """
        self.configure_response(
            proxy_manager={'http://': 'http://local.proxy:3939'}, )
        self.configure_request(
            url='https://example.com',
            method='GET',
        )

        assert dump._get_proxy_information(self.response) == {
            'method': 'CONNECT',
            'request_path': 'https://example.com'
        }
    def test_get_proxy_information_with_proxy_over_https(self):
        """Show that the request path and method are returned for HTTPS reqs.

        Using HTTPS over a proxy changes the method used and the request path.
        """
        self.configure_response(
            proxy_manager={'http://': 'http://local.proxy:3939'},
        )
        self.configure_request(
            url='https://example.com',
            method='GET',
        )

        assert dump._get_proxy_information(self.response) == {
            'method': 'CONNECT',
            'request_path': 'https://example.com'
        }
Exemple #3
0
    def test_get_proxy_information_with_proxy_over_http(self):
        """Show only the request path is returned for HTTP requests.

        Using HTTP over a proxy doesn't alter anything except the request path
        of the request. The method doesn't change a dictionary with the
        request_path is the only thing that should be returned.
        """
        self.configure_response(
            proxy_manager={'http://': 'http://local.proxy:3939'}, )
        self.configure_request(
            url='http://example.com',
            method='GET',
        )

        assert dump._get_proxy_information(self.response) == {
            'request_path': 'http://example.com'
        }
    def test_get_proxy_information_with_proxy_over_http(self):
        """Show only the request path is returned for HTTP requests.

        Using HTTP over a proxy doesn't alter anything except the request path
        of the request. The method doesn't change a dictionary with the
        request_path is the only thing that should be returned.
        """
        self.configure_response(
            proxy_manager={'http://': 'http://local.proxy:3939'},
        )
        self.configure_request(
            url='http://example.com',
            method='GET',
        )

        assert dump._get_proxy_information(self.response) == {
            'request_path': 'http://example.com'
        }
def dump_response(response,
                  request_prefix=b'',
                  response_prefix=b'',
                  data_array=None,
                  n=0):
    data = data_array if data_array is not None else bytearray()
    prefixes = PrefixSettings(request_prefix, response_prefix)

    if not hasattr(response, 'request'):
        raise ValueError('Response has no associated request')

    proxy_info = _get_proxy_information(response)
    _dump_request_data_only(response.request,
                            prefixes,
                            data,
                            proxy_info=proxy_info,
                            n=n)
    _dump_response_data_only(response, prefixes, data, n=n)
    return data
    def test_get_proxy_information_sans_proxy(self):
        """Show no information is returned when not using a proxy."""
        self.configure_response()

        assert dump._get_proxy_information(self.response) is None
Exemple #7
0
    def test_get_proxy_information_sans_proxy(self):
        """Show no information is returned when not using a proxy."""
        self.configure_response()

        assert dump._get_proxy_information(self.response) is None