Skip to content
Myr

Merge branch 'curl_feature' of https://github.com/mawaldne/requests into feature/curl

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

authored by Kenneth Reitz · committed by Kenneth Reitz · parents 1d0a5b2, 0bf60c8 · Browse files · 1 file+35 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+35 added−0 removed

  • other:+35 added−0 removed

1 file+35 added−0 removed

modified:requests/models.py+35 added
381 unmodified lines
382 self.sent = self.response.ok383384 return self.sent385386 @property387 def curl(self):388 """Creates a curl command from the request"""389390 #TODO - Auth with User names and accounts391 #TODO - Files392 #TODO - OAuth393 #TODO - Cookies?394395 #: -L/--location - if there is a redirect, redo request on the new place396 curl_cmd = 'curl -L '397398 #: -H/--header - Extra header to use when getting a web page399 header = ''400 if self.headers:401 header = header.join(['-H "' + key + ':' + value + '" ' for key, value in self.headers.iteritems()])402403 if self.method.upper() == 'HEAD':404 #: -I/--head - fetch headers only405 method_opt = '-I '406 else:407 #: -X/--request - specify request method408 method_opt = '-X %s ' % self.method.upper()409410 data = ''411 if self.method in ('PUT', 'POST', 'PATCH'):412 #: -d/--data - send specified data in post request.413 if isinstance(self.data, (list, tuple)):414 data = data.join(['-d ' + key + '=' + value + ' ' for key, value in self.data])415 elif self._enc_data is not None:416 data = '-d ' + self._enc_data + ' '417418 #: Params handled in _build_url419 return curl_cmd + method_opt + data + header + '"' + self._build_url() + '"'420421422class Response(object):423 """The core :class:`Response <Response>` object. All424 :class:`Request <Request>` objects contain a425 :class:`response <Response>` attribute, which is an instance
256 unmodified lines