src/r/s/rsl-0.2.1/src/rsl/misc/http.py rsl(Download)
import md5 from urllib2 import Request as Urllib2Request from urllib2 import HTTPPasswordMgrWithDefaultRealm, BaseHandler from urllib2 import HTTPCookieProcessor from urllib2 import HTTPBasicAuthHandler, build_opener, install_opener from cookielib import LWPCookieJar
class CacheHandler(BaseHandler):
"""Stores responses in a persistant on-disk cache.
If a subsequent GET request is made for the same URL, the stored
response is returned, saving time, resources and bandwith"""
def __init__(self, cachelocation):
"""The location of the cache directory"""
src/k/e/keeprunning-HEAD/twill/other_packages/_mechanize_dist/_urllib2.py keeprunning(Download)
# handlers...
# ...from urllib2...
from urllib2 import \
BaseHandler, \
UnknownHandler, \
FTPHandler, \
src/k/e/keeprunning-HEAD/twill/other_packages/_mechanize_dist/_http.py keeprunning(Download)
import copy, time, tempfile, htmlentitydefs, re, logging, socket, \
urllib2, urllib, httplib, sgmllib
from urllib2 import URLError, HTTPError, BaseHandler
from cStringIO import StringIO
from _request import Request
class HTTPRedirectHandler(BaseHandler):
# maximum number of redirections to any single URL
# this is needed because of the state that cookies introduce
max_repeats = 4
# maximum total number of redirections (regardless of URL) before
# assuming we're in a loop
max_redirections = 10
class HTTPEquivProcessor(BaseHandler):
"""Append META HTTP-EQUIV headers to regular HTTP headers."""
handler_order = 300 # before handlers that look at HTTP headers
def __init__(self, head_parser_class=HeadParser,
i_want_broken_xhtml_support=False,
class HTTPCookieProcessor(BaseHandler):
"""Handle HTTP cookies.
Public attributes:
cookiejar: CookieJar instance
class HTTPRobotRulesProcessor(BaseHandler):
# before redirections, after everything else
handler_order = 800
try:
from httplib import HTTPMessage
except:
class HTTPRefererProcessor(BaseHandler):
"""Add Referer header to requests.
This only makes sense if you use each RefererProcessor for a single
chain of requests only (so, for example, if you use a single
HTTPRefererProcessor to fetch a series of URLs extracted from a single
page, this will break).
class HTTPRefreshProcessor(BaseHandler):
"""Perform HTTP Refresh redirections.
Note that if a non-200 HTTP code has occurred (for example, a 30x
redirect), this processor will do nothing.
By default, only zero-time Refresh headers are redirected. Use the
class HTTPErrorProcessor(BaseHandler):
"""Process HTTP error responses.
The purpose of this handler is to to allow other response processors a
look-in by removing the call to parent.error() from
AbstractHTTPHandler.
class HTTPDefaultErrorHandler(BaseHandler):
def http_error_default(self, req, fp, code, msg, hdrs):
# why these error methods took the code, msg, headers args in the first
# place rather than a response object, I don't know, but to avoid
# multiple wrapping, we're discarding them
if isinstance(fp, urllib2.HTTPError):
class AbstractHTTPHandler(BaseHandler):
def __init__(self, debuglevel=0):
self._debuglevel = debuglevel
def set_http_debuglevel(self, level):
self._debuglevel = level
src/k/e/keeprunning-HEAD/twill/other_packages/_mechanize_dist/_debug.py keeprunning(Download)
import logging from urllib2 import BaseHandler from _response import response_seek_wrapper class HTTPResponseDebugProcessor(BaseHandler):
class HTTPRedirectDebugProcessor(BaseHandler):
def http_request(self, request):
if hasattr(request, "redirect_dict"):
info = logging.getLogger("mechanize.http_redirects").info
info("redirecting to %s", request.get_full_url())
return request
src/k/e/keeprunning-HEAD/twill/other_packages/_mechanize_dist/_auth.py keeprunning(Download)
import re, base64, urlparse, posixpath, md5, sha, sys, copy
from urllib2 import BaseHandler
from urllib import getproxies, unquote, splittype, splituser, splitpasswd, \
splitport
class ProxyHandler(BaseHandler):
# Proxies must be in front
handler_order = 100
def __init__(self, proxies=None):
if proxies is None:
proxies = getproxies()
class HTTPBasicAuthHandler(AbstractBasicAuthHandler, BaseHandler):
auth_header = 'Authorization'
def http_error_401(self, req, fp, code, msg, headers):
url = req.get_full_url()
return self.http_error_auth_reqed('www-authenticate',
url, req, headers)
class ProxyBasicAuthHandler(AbstractBasicAuthHandler, BaseHandler):
class HTTPDigestAuthHandler(BaseHandler, AbstractDigestAuthHandler):
"""An authentication protocol defined by RFC 2069
Digest authentication improves on basic authentication because it
does not transmit passwords in the clear.
"""
class ProxyDigestAuthHandler(BaseHandler, AbstractDigestAuthHandler):
auth_header = 'Proxy-Authorization'
handler_order = 490
def http_error_407(self, req, fp, code, msg, headers):
host = req.get_host()
src/k/e/keeprunning-HEAD/twill/other_packages/_mechanize_dist/_upgrade.py keeprunning(Download)
from urllib2 import BaseHandler from _request import Request from _response import upgrade_response from _util import deprecation class HTTPRequestUpgradeProcessor(BaseHandler):
class ResponseUpgradeProcessor(BaseHandler):
# upgrade responses to be .close()able without becoming unusable
handler_order = 0 # before anything else
def __init__(self):
deprecation(
"See http://wwwsearch.sourceforge.net/mechanize/doc.html#seekable")
src/k/e/keeprunning-HEAD/twill/other_packages/_mechanize_dist/_seek.py keeprunning(Download)
from urllib2 import BaseHandler
from _util import deprecation
from _response import response_seek_wrapper
class SeekableProcessor(BaseHandler):
"""Deprecated: Make responses seekable."""
src/h/r/hrafn-HEAD/oauthtwitter.py hrafn(Download)
import oauth.oauth as oauth import time from urllib import urlencode from urllib2 import BaseHandler # Taken from oauth implementation at: http://github.com/harperreed/twitteroauth-python/tree/master REQUEST_TOKEN_URL = 'https://twitter.com/oauth/request_token' ACCESS_TOKEN_URL = 'https://twitter.com/oauth/access_token' AUTHORIZATION_URL = 'http://twitter.com/oauth/authorize' SIGNIN_URL = 'http://twitter.com/oauth/authenticate' class LoggingHandler(BaseHandler):