def prepare_request(self, request):
cookies = request.cookies or {}<EOL>if not isinstance(cookies, cookielib.CookieJar):<EOL><INDENT>cookies = cookiejar_from_dict(cookies)<EOL><DEDENT>merged_cookies = merge_cookies(<EOL>merge_cookies(RequestsCookieJar(), self.cookies), cookies)<EOL>auth = request.auth<EOL>if self.trust_env and not auth and not self.auth:<EOL><INDENT>auth = get_netrc_auth(request.url)<EOL><DEDENT>p = PreparedRequest()<EOL>p.prepare(<EOL>method=request.method.upper(),<EOL>url=request.url,<EOL>files=request.files,<EOL>data=request.data,<EOL>json=request.json,<EOL>headers=merge_setting(request.headers, self.headers, dict_class=CaseInsensitiveDict),<EOL>params=merge_setting(request.params, self.params),<EOL>auth=merge_setting(auth, self.auth),<EOL>cookies=merged_cookies,<EOL>hooks=merge_hooks(request.hooks, self.hooks),<EOL>)<EOL>return p<EOL>
Constructs a :class:`PreparedRequest <PreparedRequest>` for
        transmission and returns it. The :class:`PreparedRequest` has settings
        merged from the :class:`Request <Request>` instance and those of the
        :class:`Session`.

        :param request: :class:`Request` instance to prepare with this
            session's settings.