Skip to content
Myr

Adding cookies

Before adoption: this commit came in with the history the project adopted, so no landing records it.

#139

authored by Mike Waldner · committed by Mike Waldner · parent 7fa4fda · Browse files · 1 file+9 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+9 added−2 removed

  • other:+9 added−2 removed

1 file+9 added−2 removed

modified:requests/utils.py+9 added-2 removed
170 unmodified lines
171def curl_from_request(request):172 """Creates a curl command from the request."""173174 #TODO - OAuth175 #TODO - Cookies175176 #: -L/--location - if there is a redirect, redo request on the new place177 curl = 'curl -L '178
2 unmodified lines
181 auth = ''182 if request.auth is not None:183 auth = '-u "%s:%s" ' % (request.auth.username, request.auth.password)184185 method = ''186 if request.method.upper() == 'HEAD':187 #: -I/--head - fetch headers only188 method = '-I '189 else:190 #: -X/--request - specify request method191 method = '-X %s ' % request.method.upper()192193 #: -b/--cookie194 #: (HTTP) Pass the data to the HTTP server as a cookie. It is supposedly the195 #: data previously received from the server in a "Set-Cookie:" line. 196 cookies = ''197 if request.cookiejar:198 cookies = cookies.join(['-b "%s=%s" ' % (k.name, k.value) for k in request.cookiejar]) 199200 #: -H/--header - Extra header to use when getting a web page201 header = ''202 if request.headers:203 header = header.join(['-H "%s:%s" ' % (k, v) for k, v in request.headers.iteritems()])
18 unmodified lines
222 elif request._enc_data not in (None, ''):223 form = "-d '%s' " % (request._enc_data)224225 #: Params handled in _build_url219 return curl + auth + method + header + form + '"' + request._build_url() + '"'226 return curl + auth + method + header + cookies + form + '"' + request._build_url() + '"'227