Skip to content
Myr

Using build_url and also including headers

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 430e87d · 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/models.py+9 added-2 removed
331 unmodified lines
332 def curl(self):333 """Creates a curl command from the request"""334335 #TODO - Auth. User names and accounts336 #TODO - Query string...336 #TODO - Files...How do I do files???337338 #: --location - if there is a redirect, redo request on the new place339 curl_cmd = 'curl --location '340341 #: --header - Extra header to use when getting a web page342 header = ''343 if self.headers:344 header = header.join(['--header "' + key + ':' + value + '" ' for key, value in self.headers.iteritems()])345346 if self.method.upper() == 'HEAD':347 #: --head - fetch headers only348 method_opt = '--head '349 else:
8 unmodified lines
358359 #if data is file:360 if isinstance(self.data, (list, tuple)):361 data = data.join(['--data ' + key + '=' + value + ' ' for key, value in self.data])362 else:363 data = '--data ' + self._enc_data + ' '364359 curl_cmd = curl_cmd + method_opt + data + self.url365 #: Params handled in _build_url366 curl_cmd = curl_cmd + method_opt + data + header + '"' + self._build_url() + '"'367368 return curl_cmd369370
231 unmodified lines