Skip to content
Myr

Merge branch 'timeout' of https://github.com/jgorset/requests into develop

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 f6f636f, 39e9424 · Browse files · 2 files+17 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

2 files+17 added−12 removed

  • other:+17 added−12 removed

2 files+17 added−12 removed

modified:requests/core.py+16 added-12 removed
12 unmodified lines
13from __future__ import absolute_import1415import urllib16import urllib217import socket18import zlib1920from urllib2 import HTTPError21from urlparse import urlparse
41 unmodified lines
6364 _METHODS = ('GET', 'HEAD', 'PUT', 'POST', 'DELETE')6566 def __init__(self, url=None, headers=dict(), files=None, method=None,66 data=dict(), auth=None, cookiejar=None):67 data=dict(), auth=None, cookiejar=None, timeout=None):6869 self.url = url70 self.headers = headers71 self.files = files72 self.method = method73 self.data = data74 75 socket.setdefaulttimeout(timeout)7677 # url encode data if it's a dict78 if hasattr(data, 'items'):79 self._enc_data = urllib.urlencode(data)
370 unmodified lines
450 data = kwargs.pop('data', dict()) or kwargs.pop('params', dict())451452 r = Request(method=method, url=url, data=data, headers=kwargs.pop('headers', {}),453 cookiejar=kwargs.pop('cookies', None), files=kwargs.pop('files', None),451 auth=kwargs.pop('auth', auth_manager.get_auth(url)))454 auth=kwargs.pop('auth', auth_manager.get_auth(url)),455 timeout=kwargs.pop('timeout', None))456 r.send()457458 return r.response459460457def get(url, params={}, headers={}, cookies=None, auth=None):461def get(url, params={}, headers={}, cookies=None, auth=None, timeout=None):462 """Sends a GET request. Returns :class:`Response` object.463464 :param url: URL for the new :class:`Request` object.465 :param params: (optional) Dictionary of GET Parameters to send with the :class:`Request`.
1 unmodified line
467 :param cookies: (optional) CookieJar object to send with the :class:`Request`.468 :param auth: (optional) AuthObject to enable Basic HTTP Auth.469 """470467 return request('GET', url, params=params, headers=headers, cookies=cookies, auth=auth)471 return request('GET', url, params=params, headers=headers, cookies=cookies, auth=auth, timeout=timeout)472473470def head(url, params={}, headers={}, cookies=None, auth=None):474def head(url, params={}, headers={}, cookies=None, auth=None, timeout=None):475 """Sends a HEAD request. Returns :class:`Response` object.476477 :param url: URL for the new :class:`Request` object.478 :param params: (optional) Dictionary of GET Parameters to send with the :class:`Request`.
1 unmodified line
480 :param cookies: (optional) CookieJar object to send with the :class:`Request`.481 :param auth: (optional) AuthObject to enable Basic HTTP Auth.482 """483480 return request('HEAD', url, params=params, headers=headers, cookies=cookies, auth=auth)484 return request('HEAD', url, params=params, headers=headers, cookies=cookies, auth=auth, timeout=timeout)485486483def post(url, data={}, headers={}, files=None, cookies=None, auth=None):487def post(url, data={}, headers={}, files=None, cookies=None, auth=None, timeout=None):488 """Sends a POST request. Returns :class:`Response` object.489490 :param url: URL for the new :class:`Request` object.491 :param data: (optional) Dictionary of POST data to send with the :class:`Request`.
2 unmodified lines
494 :param cookies: (optional) CookieJar object to send with the :class:`Request`.495 :param auth: (optional) AuthObject to enable Basic HTTP Auth.496 """497494 return request('POST', url, data=data, headers=headers, files=files, cookies=cookies, auth=auth)498 return request('POST', url, data=data, headers=headers, files=files, cookies=cookies, auth=auth, timeout=timeout)499500497def put(url, data='', headers={}, files={}, cookies=None, auth=None):501def put(url, data='', headers={}, files={}, cookies=None, auth=None, timeout=None):502 """Sends a PUT request. Returns :class:`Response` object.503504 :param url: URL for the new :class:`Request` object.505 :param params: (optional) Bytes of PUT Data to send with the :class:`Request`.
2 unmodified lines
508 :param cookies: (optional) CookieJar object to send with the :class:`Request`.509 :param auth: (optional) AuthObject to enable Basic HTTP Auth.510 """511508 return request('PUT', url, data=data, headers=headers, files=files, cookies=cookies, auth=auth)512 return request('PUT', url, data=data, headers=headers, files=files, cookies=cookies, auth=auth, timeout=timeout)513514511def delete(url, params={}, headers={}, cookies=None, auth=None):515def delete(url, params={}, headers={}, cookies=None, auth=None, timeout=None):516 """Sends a DELETE request. Returns :class:`Response` object.517518 :param url: URL for the new :class:`Request` object.519 :param params: (optional) Dictionary of DELETE Parameters to send with the :class:`Request`.
1 unmodified line
521 :param cookies: (optional) CookieJar object to send with the :class:`Request`.522 :param auth: (optional) AuthObject to enable Basic HTTP Auth.523 """524521 return request('DELETE', url, params=params, headers=headers, cookies=cookies, auth=auth)525 return request('DELETE', url, params=params, headers=headers, cookies=cookies, auth=auth, timeout=timeout)526527528529class RequestException(Exception):
11 unmodified lines
modified:AUTHORS+1 added
15 unmodified lines
16- Dj Gilcrease17- Justin Murphy18- Rob Madole19- Aram Dulyan20- Johannes Gorset