Skip to content
Myr

Sphinx Documentation

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 3f98034 · Browse files · 2 files+22 added−8 removed
This commit

State

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

Diff stats

2 files+22 added−8 removed

  • other:+22 added−8 removed

2 files+22 added−8 removed

modified:docs/api.rst+4 added
46 unmodified lines
47.. autofunction:: dict_from_cookiejar48.. autofunction:: cookiejar_from_dict49.. autofunction:: add_dict_to_cookiejar5051Curl52~~~~53.. autofunction:: curl_from_request5455Encodings56~~~~~~~~~5758.. autofunction:: get_encodings_from_content
35 unmodified lines
modified:requests/utils.py+18 added-8 removed
167 unmodified lines
168 return zlib.decompress(content, 16+zlib.MAX_WBITS)169170171def curl_from_request(request):172 """Creates a curl command from the request."""172 """Returns a curl command from the request.173174 :param request: The :class:`Request <Request>` object175176 Example:177 | import requests178 | from requests.utils import curl_from_request179 | r = requests.get('http://httpbin.org/get')180 | curl_from_request(r.request)181182 """183184 #TODO - OAuth185176 #: -L/--location - if there is a redirect, redo request on the new place186 #: -L/--location - if there is a redirect, redo request on the new place.187 curl = 'curl -L '188189 #: -u/--user - Specify the user name and password to use for server auth.190 #: Basic Auth only for now
2 unmodified lines
193 auth = '-u "%s:%s" ' % (request.auth.username, request.auth.password)194195 method = ''196 if request.method.upper() == 'HEAD':187 #: -I/--head - fetch headers only197 #: -I/--head - fetch headers only.198 method = '-I '199 else:190 #: -X/--request - specify request method200 #: -X/--request - specify request method.201 method = '-X %s ' % request.method.upper()202203 #: -b/--cookie204 #: (HTTP) Pass the data to the HTTP server as a cookie. It is supposedly the
1 unmodified line
206 cookies = ''207 if request.cookiejar:208 cookies = cookies.join(['-b "%s=%s" ' % (k.name, k.value) for k in request.cookiejar])209200 #: -H/--header - Extra header to use when getting a web page210 #: -H/--header - Extra header to use when getting a web page.211 header = ''212 if request.headers:213 header = header.join(['-H "%s:%s" ' % (k, v) for k, v in request.headers.iteritems()])214215 form = ''216 if request.method in ('PUT', 'POST', 'PATCH'):207 #: request.files is updated with request.data if both exist.208 #: ContentType multipart/form-data is used217 #: request.files is updated with request.data if both exist, so only iterate request.files.218 #: ContentType multipart/form-data is used.219 if request.files:220 #: -F/--form - Emulate form data. To force 'content' to a file, prefix file name @.221 for k, v in request.files.iteritems():222 if isinstance(v, file):223 form = form + '-F "%s=@%s" ' % (k, v.name)224 elif v not in (None, ''):225 form = form + '-F "%s=%s" ' % (k, v)226217 #: content-type application/x-www-form-urlencoded is used here227 #: content-type application/x-www-form-urlencoded is used here.228 else:229 #: -d/--data - send specified data in post request.230 if isinstance(request.data, (list, tuple)):231 form = form.join(['-d "%s=%s" ' % (k, v) for k, v in request.data])
6 unmodified lines