def http_request(self, request): unverifiable = self._unverifiable(request) if not unverifiable: # Stuff request-host of this origin transaction into Request # object, because we need to know it to know whether cookies # should be in operation during derived requests (redirects, # specifically -- including refreshes). request.origin_req_host = request_host(request) self.cookies.add_cookie_header(request, unverifiable) return request
def __init__(self, url, data=None, headers={}, origin_req_host=None, unverifiable=False): urllib2.Request.__init__(self, url, data, headers) self.unredirected_hdrs = {} # 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(self) self.origin_req_host = origin_req_host