merge changes

This commit is contained in:
Kenneth Reitz
2011-02-24 01:50:38 -05:00
parent 1f60e1004c
commit e7b8e9371a
2 changed files with 24 additions and 11 deletions
+10 -8
View File
@@ -10,11 +10,13 @@
:license: ISC, see LICENSE for more details.
"""
from __future__ import absolute_import
import urllib
import urllib2
from urllib2 import HTTPError
try:
import eventlet
eventlet.monkey_patch()
@@ -28,16 +30,16 @@ if not 'eventlet' in locals():
except ImportError:
pass
if not 'eventlet' in locals():
raise ImportError('No Async adaptations of urllib2 found!')
from .core import *
__all__ = ['Request', 'Response', 'request', 'get', 'head', 'post', 'put', 'delete', 'auth_manager', 'AuthObject',
'RequestException', 'AuthenticationError', 'URLRequired', 'InvalidMethod', 'HTTPError']
__title__ = 'requests'
__version__ = '0.0.1'
__build__ = 0x000001
__author__ = 'Dj Gilcrease'
__license__ = 'ISC'
__copyright__ = 'Copyright 2011 Kenneth Reitz'
__all__ = [
'Request', 'Response', 'request', 'get', 'head', 'post', 'put', 'delete',
'auth_manager', 'AuthObject','RequestException', 'AuthenticationError',
'URLRequired', 'InvalidMethod', 'HTTPError'
]
+14 -3
View File
@@ -18,15 +18,21 @@ from urllib2 import HTTPError
from .packages.poster.encode import multipart_encode
from .packages.poster.streaminghttp import register_openers
__all__ = ['Request', 'Response', 'request', 'get', 'head', 'post', 'put', 'delete', 'auth_manager', 'AuthObject',
'RequestException', 'AuthenticationError', 'URLRequired', 'InvalidMethod', 'HTTPError']
__title__ = 'requests'
__version__ = '0.2.5'
__build__ = 0x000205
__author__ = 'Kenneth Reitz, Dj Gilcrease'
__author__ = 'Kenneth Reitz'
__license__ = 'ISC'
__copyright__ = 'Copyright 2011 Kenneth Reitz'
__all__ = [
'Request', 'Response', 'request', 'get', 'head', 'post', 'put', 'delete',
'auth_manager', 'AuthObject','RequestException', 'AuthenticationError',
'URLRequired', 'InvalidMethod', 'HTTPError'
]
class _Request(urllib2.Request):
"""Hidden wrapper around the urllib2.Request object. Allows for manual
setting of HTTP methods.
@@ -199,6 +205,8 @@ class Response(object):
if self.error:
raise self.error
class AuthManager(object):
def __new__(cls):
singleton = cls.__dict__.get('__singleton__')
@@ -354,6 +362,7 @@ def request(method, url, **kwargs):
return r.response
def get(url, params={}, headers={}, cookies=None, auth=None):
"""Sends a GET request. Returns :class:`Response` object.
@@ -420,6 +429,8 @@ def delete(url, params={}, headers={}, cookies=None, auth=None):
return request('DELETE', url, params=params, headers=headers, cookiejar=cookies, auth=auth)
class RequestException(Exception):
"""There was an ambiguous exception that occured while handling your
request."""