Exemple #1
0
    def __init__(self,
                 url,
                 data=None,
                 headers={},
                 origin_req_host=None,
                 unverifiable=False,
                 visit=None,
                 timeout=_sockettimeout._GLOBAL_DEFAULT_TIMEOUT):
        # In mechanize 0.2, the interpretation of a unicode url argument will
        # change: A unicode url argument will be interpreted as an IRI, and a
        # bytestring as a URI. For now, we accept unicode or bytestring.  We
        # don't insist that the value is always a URI (specifically, must only
        # contain characters which are legal), because that might break working
        # code (who knows what bytes some servers want to see, especially with
        # browser plugins for internationalised URIs).
        if not _rfc3986.is_clean_uri(url):
            warn("url argument is not a URI "
                 "(contains illegal characters) %r" % url)
        urllib2.Request.__init__(self, url, data, headers)
        self.selector = None
        self.unredirected_hdrs = {}
        self.visit = visit
        self.timeout = timeout

        # All the terminology below comes from RFC 2965.
        self.unverifiable = unverifiable
        # Set request-host of origin transaction.
        # The origin request-host is needed in order to decide whether
        # unverifiable sub-requests (automatic redirects, images embedded
        # in HTML, etc.) are to third-party hosts.  If they are, the
        # resulting transactions might need to be conducted with cookies
        # turned off.
        if origin_req_host is None:
            origin_req_host = request_host_lc(self)
        self.origin_req_host = origin_req_host
Exemple #2
0
    def __init__(self, url, data=None, headers={},
                 origin_req_host=None, unverifiable=False, visit=None,
                 timeout=_sockettimeout._GLOBAL_DEFAULT_TIMEOUT):
        # In mechanize 0.2, the interpretation of a unicode url argument will
        # change: A unicode url argument will be interpreted as an IRI, and a
        # bytestring as a URI. For now, we accept unicode or bytestring.  We
        # don't insist that the value is always a URI (specifically, must only
        # contain characters which are legal), because that might break working
        # code (who knows what bytes some servers want to see, especially with
        # browser plugins for internationalised URIs).
        if not _rfc3986.is_clean_uri(url):
            warn("url argument is not a URI "
                 "(contains illegal characters) %r" % url)
        urllib2.Request.__init__(self, url, data, headers)
        self.selector = None
        self.unredirected_hdrs = {}
        self.visit = visit
        self.timeout = timeout

        # All the terminology below comes from RFC 2965.
        self.unverifiable = unverifiable
        # Set request-host of origin transaction.
        # The origin request-host is needed in order to decide whether
        # unverifiable sub-requests (automatic redirects, images embedded
        # in HTML, etc.) are to third-party hosts.  If they are, the
        # resulting transactions might need to be conducted with cookies
        # turned off.
        if origin_req_host is None:
            origin_req_host = request_host_lc(self)
        self.origin_req_host = origin_req_host
Exemple #3
0
 def __init__(self, url, data=None, headers={},
              origin_req_host=None, unverifiable=False, visit=None,
              timeout=_sockettimeout._GLOBAL_DEFAULT_TIMEOUT):
     # In mechanize 0.2, the interpretation of a unicode url argument will
     # change: A unicode url argument will be interpreted as an IRI, and a
     # bytestring as a URI. For now, we accept unicode or bytestring.  We
     # don't insist that the value is always a URI (specifically, must only
     # contain characters which are legal), because that might break working
     # code (who knows what bytes some servers want to see, especially with
     # browser plugins for internationalised URIs).
     if not _rfc3986.is_clean_uri(url):
         warn("url argument is not a URI "
              "(contains illegal characters) %r" % url)
     _urllib2_fork.Request.__init__(self, url, data, headers)
     self.selector = None
     self.visit = visit
     self.timeout = timeout
 def __init__(self, url, data=None, headers={},
              origin_req_host=None, unverifiable=False, visit=None,
              timeout=_sockettimeout._GLOBAL_DEFAULT_TIMEOUT):
     # In mechanize 0.2, the interpretation of a unicode url argument will
     # change: A unicode url argument will be interpreted as an IRI, and a
     # bytestring as a URI. For now, we accept unicode or bytestring.  We
     # don't insist that the value is always a URI (specifically, must only
     # contain characters which are legal), because that might break working
     # code (who knows what bytes some servers want to see, especially with
     # browser plugins for internationalised URIs).
     if not _rfc3986.is_clean_uri(url):
         warn("url argument is not a URI "
              "(contains illegal characters) %r" % url)
     _urllib2_fork.Request.__init__(self, url, data, headers)
     self.selector = None
     self.visit = visit
     self.timeout = timeout