From b72e1d19aff997d00ef617a3aa0eea8ccdcc3984 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sun, 13 Feb 2011 16:16:36 -0500 Subject: [PATCH] AuthAuths --- requests/core.py | 48 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 5 deletions(-) diff --git a/requests/core.py b/requests/core.py index 876e701..81f8bc7 100644 --- a/requests/core.py +++ b/requests/core.py @@ -9,6 +9,7 @@ :copyright: (c) 2011 by Kenneth Reitz. :license: ISC, see LICENSE for more details. """ +import urllib import urllib2 @@ -20,16 +21,41 @@ __license__ = 'ISC' __copyright__ = 'Copyright 2011 Kenneth Reitz' +AUTHOAUTHS = [] + + class Request(object): """The :class:`Request` object. It's awesome. """ - pass + _METHODS = ('get', 'put', 'post', 'delete') + + def __init__(self): + self.headers = dict() + self.method = None + self.response = None + + def __setattr__(self, key, val): + if key == 'method': + if not val.lower() in _METHODS: + raise InvalidMethod() + + def send(self): + pass + set self.response() + # return True / False + class Response(object): """The :class:`Request` object. It's awesome. """ + def __init__(self): + self.content = None + self.status_code = None + self.headers = dict() + + class AuthObject(object): """The :class:`AuthObject` is a simple HTTP Authentication token. @@ -42,15 +68,27 @@ class AuthObject(object): self.password = password -def get(): +def get(url, params={}, headers={}, auth=None): pass -def post(): +def head(url, params={}, headers={}, auth=None): + pass + +def post(url, params={}, headers={}, auth=None): pass -def put(): +def put(url, data='', headers={}, auth=None): pass -def delete(): +def delete(url, params={}, headers={}, auth=None): pass + + +def add_autoauth(url, authobject): + global AUTHOAUTHS + + AUTHOAUTHS.append((url, authobject)) + +class InvalidMethod(Exception): + """An innappropriate method was attempted.""" \ No newline at end of file -- 2.34.1