httplib2 Package

httplib2 Package

class httplib2.Http(cache=None, timeout=None, proxy_info=<bound method type.from_environment of <class 'httplib2.ProxyInfo'>>, ca_certs=None, disable_ssl_certificate_validation=False)[source]

Bases: object

An HTTP client that handles: - all methods - caching - ETags - compression, - HTTPS - Basic - Digest - WSSE

and more.

add_certificate(key, cert, domain)[source]

Add a key and cert that will be used any time a request requires authentication.

add_credentials(name, password, domain='')[source]

Add a name and password that will be used any time a request requires authentication.

clear_credentials()[source]

Remove all the names and passwords that are used for authentication

request(uri, method='GET', body=None, headers=None, redirections=5, connection_type=None)[source]

Performs a single HTTP request. The ‘uri’ is the URI of the HTTP resource and can begin with either ‘http’ or ‘https’. The value of ‘uri’ must be an absolute URI.

The ‘method’ is the HTTP method to perform, such as GET, POST, DELETE, etc. There is no restriction on the methods allowed.

The ‘body’ is the entity body to be sent with the request. It is a string object.

Any extra headers that are to be sent with the request should be provided in the ‘headers’ dictionary.

The maximum number of redirect to follow before raising an exception is ‘redirections. The default is 5.

The return value is a tuple of (response, content), the first being and instance of the ‘Response’ class, the second being a string that contains the response entity body.

class httplib2.Response(info)[source]

Bases: dict

An object more like email.Message than httplib.HTTPResponse.

fromcache = False

HTTP protocol version used by server. 10 for HTTP/1.0, 11 for HTTP/1.1.

previous = None
reason = 'Ok'
status = 200

Reason phrase returned by server.

version = 11

Status code returned by server.

class httplib2.ProxyInfo(proxy_type, proxy_host, proxy_port, proxy_rdns=None, proxy_user=None, proxy_pass=None)[source]

Bases: object

Collect information required to use a proxy.

applies_to(hostname)[source]
astuple()[source]
bypass_host(hostname)[source]

Has this host been excluded from the proxy config

bypass_hosts = ()
classmethod from_environment(method='http')[source]

Read proxy info from the environment variables.

classmethod from_url(url, method='http')[source]

Construct a ProxyInfo from a URL (such as http_proxy env var)

isgood()[source]
exception httplib2.HttpLib2Error[source]

Bases: exceptions.Exception

exception httplib2.RedirectMissingLocation(desc, response, content)[source]

Bases: httplib2.HttpLib2ErrorWithResponse

exception httplib2.RedirectLimit(desc, response, content)[source]

Bases: httplib2.HttpLib2ErrorWithResponse

exception httplib2.FailedToDecompressContent(desc, response, content)[source]

Bases: httplib2.HttpLib2ErrorWithResponse

exception httplib2.UnimplementedDigestAuthOptionError(desc, response, content)[source]

Bases: httplib2.HttpLib2ErrorWithResponse

exception httplib2.UnimplementedHmacDigestAuthOptionError(desc, response, content)[source]

Bases: httplib2.HttpLib2ErrorWithResponse

exception httplib2.ProxiesUnavailableError[source]

Bases: httplib2.HttpLib2Error

iri2uri Module

iri2uri

Converts an IRI to a URI.

httplib2.iri2uri.encode(c)[source]
httplib2.iri2uri.iri2uri(uri)[source]

Convert an IRI to a URI. Note that IRIs must be passed in a unicode strings. That is, do not utf-8 encode the IRI before passing it into the function.

socks Module

SocksiPy - Python SOCKS module. Version 1.00

Copyright 2006 Dan-Haim. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this

list of conditions and the following disclaimer.
  1. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  2. Neither the name of Dan Haim nor the names of his contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY DAN HAIM “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DAN HAIM OR HIS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMANGE.

This module provides a standard socket-like interface for Python for tunneling connections through SOCKS proxies.

exception httplib2.socks.GeneralProxyError[source]

Bases: httplib2.socks.ProxyError

exception httplib2.socks.HTTPError[source]

Bases: httplib2.socks.ProxyError

exception httplib2.socks.ProxyError[source]

Bases: exceptions.Exception

exception httplib2.socks.Socks4Error[source]

Bases: httplib2.socks.ProxyError

exception httplib2.socks.Socks5AuthError[source]

Bases: httplib2.socks.ProxyError

exception httplib2.socks.Socks5Error[source]

Bases: httplib2.socks.ProxyError

httplib2.socks.setdefaultproxy(proxytype, addr[, port[, rdns[, username[, password]]]])[source]

Sets a default proxy which all further socksocket objects will use, unless explicitly changed.

class httplib2.socks.socksocket(family=2, type=1, proto=0, _sock=None)[source]

Bases: socket._socketobject

socksocket([family[, type[, proto]]]) -> socket object Open a SOCKS enabled socket. The parameters are the same as those of the standard socket init. In order for SOCKS to work, you must specify family=AF_INET, type=SOCK_STREAM and proto=0.

connect(self, despair)[source]

Connects to the specified destination through a proxy. destpar - A tuple of the IP/DNS address and the port number. (identical to socket’s connect). To select the proxy server use setproxy().

getpeername() -> address info Returns the IP address and port number of the destination machine (note: getproxypeername returns the proxy)[source]

Returns the IP address and port number of the destination machine (note: getproxypeername returns the proxy)

getproxypeername() → address info[source]

Returns the IP and port number of the proxy.

getproxysockname()[source]

getsockname() -> address info Returns the bound IP address and port number at the proxy.

sendall(content, *args)[source]

override socket.socket.sendall method to rewrite the header for non-tunneling proxies if needed

setproxy(proxytype, addr[, port[, rdns[, username[, password]]]])[source]

Sets the proxy to be used. proxytype - The type of the proxy to be used. Three types

are supported: PROXY_TYPE_SOCKS4 (including socks4a), PROXY_TYPE_SOCKS5 and PROXY_TYPE_HTTP

addr - The address of the server (IP or DNS). port - The port of the server. Defaults to 1080 for SOCKS

servers and 8080 for HTTP proxy servers.
rdns - Should DNS queries be preformed on the remote side
(rather than the local side). The default is True. Note: This has no effect with SOCKS4 servers.
username - Username to authenticate with to the server.
The default is no authentication.
password - Password to authenticate with to the server.
Only relevant when username is also provided.
httplib2.socks.wrapmodule(module)[source]

Attempts to replace a module’s socket library with a SOCKS socket. Must set a default proxy using setdefaultproxy(...) first. This will only work on modules that import socket directly into the namespace; most of the Python Standard Library falls into this category.

Table Of Contents

Previous topic

heartbeat_server_test Module

Next topic

hypocenter_fit Module

This Page