class documentation

class PreparedRequest(RequestEncodingMixin, RequestHooksMixin):

View In Hierarchy

The fully mutable PreparedRequest object, containing the exact bytes that will be sent to the server.

Instances are generated from a Request object, and should not be instantiated manually; doing so may produce undesirable effects.

Usage:

>>> import requests
>>> req = requests.Request('GET', 'https://httpbin.org/get')
>>> r = req.prepare()
>>> r
<PreparedRequest [GET]>

>>> s = requests.Session()
>>> s.send(r)
<Response [200]>
Static Method ​_get​_idna​_encoded​_host Undocumented
Method __init__ Undocumented
Method __repr__ Undocumented
Method copy Undocumented
Method prepare Prepares the entire request with the given parameters.
Method prepare​_auth Prepares the given HTTP auth data.
Method prepare​_body Prepares the given HTTP body data.
Method prepare​_content​_length Prepare Content-Length header based on request method and body
Method prepare​_cookies Prepares the given HTTP cookie data.
Method prepare​_headers Prepares the given HTTP headers.
Method prepare​_hooks Prepares the given hooks.
Method prepare​_method Prepares the given HTTP method.
Method prepare​_url Prepares the given HTTP URL.
Instance Variable ​_body​_position Undocumented
Instance Variable ​_cookies Undocumented
Instance Variable body Undocumented
Instance Variable headers Undocumented
Instance Variable hooks Undocumented
Instance Variable method Undocumented
Instance Variable url Undocumented

Inherited from RequestEncodingMixin:

Static Method ​_encode​_files Build the body for a multipart/form-data request.
Static Method ​_encode​_params Encode parameters in a piece of data.
Property path​_url Build the path URL to use.

Inherited from RequestHooksMixin:

Method deregister​_hook Deregister a previously registered hook. Returns True if the hook existed, False if not.
Method register​_hook Properly register a hook.
@staticmethod
def _get_idna_encoded_host(host):

Undocumented

def __init__(self):

Undocumented

def __repr__(self):

Undocumented

def copy(self):

Undocumented

def prepare(self, method=None, url=None, headers=None, files=None, data=None, params=None, auth=None, cookies=None, hooks=None, json=None):
Prepares the entire request with the given parameters.
def prepare_auth(self, auth, url=''):
Prepares the given HTTP auth data.
def prepare_body(self, data, files, json=None):
Prepares the given HTTP body data.
def prepare_content_length(self, body):
Prepare Content-Length header based on request method and body
def prepare_cookies(self, cookies):

Prepares the given HTTP cookie data.

This function eventually generates a Cookie header from the given cookies using cookielib. Due to cookielib's design, the header will not be regenerated if it already exists, meaning this function can only be called once for the life of the PreparedRequest object. Any subsequent calls to prepare_cookies will have no actual effect, unless the "Cookie" header is removed beforehand.

def prepare_headers(self, headers):
Prepares the given HTTP headers.
def prepare_hooks(self, hooks):
Prepares the given hooks.
def prepare_method(self, method):
Prepares the given HTTP method.
def prepare_url(self, url, params):
Prepares the given HTTP URL.
_body_position =

Undocumented

_cookies =

Undocumented

body =

Undocumented

headers =

Undocumented

hooks =

Undocumented

method =

Undocumented

url =

Undocumented