Skip to content
Myr

First commit of curl command from request

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

authored by Mike Waldner · committed by Mike Waldner · parent 975720a · Browse files · 1 file+31 added−0 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+31 added−0 removed

  • other:+31 added−0 removed

1 file+31 added−0 removed

modified:requests/models.py+31 added
326 unmodified lines
327 self.sent = self.response.ok328329 return self.sent330331 @property332 def curl(self):333 """Creates a curl command from the request"""334335 #TODO - Auth. User names and accounts336 #TODO - Query string...337 #TODO - Files...How do I do files???338339 #: --location - if there is a redirect, redo request on the new place340 curl_cmd = 'curl --location '341342 if self.method.upper() == 'HEAD':343 #: --head - fetch headers only344 method_opt = '--head '345 else:346 #: --request - specify request method347 method_opt = '--request %s ' % self.method.upper()348349 data = ''350 if self.method in ('PUT', 'POST', 'PATCH'):351 #: --data - send specified data in post request.352 #: '-data name=John -data skill=Doe' generates the353 #: post chunk 'name=daniel&skill=lousy'354355 #if data is file:356 if isinstance(self.data, (list, tuple)):357 data = data.join(['--data ' + key + '=' + value + ' ' for key, value in self.data])358359 curl_cmd = curl_cmd + method_opt + data + self.url360361 return curl_cmd362363364class Response(object):365 """The core :class:`Response <models.Response>` object. All366 :class:`Request <models.Request>` objects contain a367 :class:`response <models.Response>` attribute, which is an instance
227 unmodified lines