Skip to content
Myr

Ive never seen anyone use the --'s unix command options

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 aad2721 · Browse files · 1 file+13 added−12 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+13 added−12 removed

  • other:+13 added−12 removed

1 file+13 added−12 removed

modified:requests/models.py+13 added-12 removed
330 unmodified lines
331 @property332 def curl(self):333 """Creates a curl command from the request"""334335 #TODO - Auth. User names and accounts336 #TODO - Files...How do I do files???335 #TODO - Auth with User names and accounts336 #TODO - Files337 #TODO - OAuth338338 #: --location - if there is a redirect, redo request on the new place339 curl_cmd = 'curl --location '339 #: -L/--location - if there is a redirect, redo request on the new place340 curl_cmd = 'curl -L '341341 #: --header - Extra header to use when getting a web page342 #: -H/--header - Extra header to use when getting a web page343 header = ''344 if self.headers:344 header = header.join(['--header "' + key + ':' + value + '" ' for key, value in self.headers.iteritems()])345 header = header.join(['-H "' + key + ':' + value + '" ' for key, value in self.headers.iteritems()])346347 if self.method.upper() == 'HEAD':347 #: --head - fetch headers only348 method_opt = '--head '348 #: -I/--head - fetch headers only349 method_opt = '-I '350 else:350 #: --request - specify request method351 method_opt = '--request %s ' % self.method.upper()351 #: -X/--request - specify request method352 method_opt = '-X %s ' % self.method.upper()353354 data = ''355 if self.method in ('PUT', 'POST', 'PATCH'):356 #: --data - send specified data in post request.
1 unmodified line
358 #: post chunk 'name=daniel&skill=lousy'359360 #if data is file:361 if isinstance(self.data, (list, tuple)):361 data = data.join(['--data ' + key + '=' + value + ' ' for key, value in self.data])362 data = data.join(['-d ' + key + '=' + value + ' ' for key, value in self.data])363 else:363 data = '--data ' + self._enc_data + ' '364 data = '-d ' + self._enc_data + ' '365366 #: Params handled in _build_url367 curl_cmd = curl_cmd + method_opt + data + header + '"' + self._build_url() + '"'368
234 unmodified lines