atom.http_core
index
/usr/local/google/home/afshar/src/external-gdata-release/google3/src/atom/http_core.py

#    Copyright (C) 2009 Google Inc.
#
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.

 
Modules
       
StringIO
httplib
os
ssl
urllib
urlparse

 
Classes
       
__builtin__.object
HttpClient
ProxiedHttpClient
HttpRequest
HttpResponse
Uri
exceptions.Exception(exceptions.BaseException)
Error
ProxyError
UnknownSize

 
class Error(exceptions.Exception)
    
Method resolution order:
Error
exceptions.Exception
exceptions.BaseException
__builtin__.object

Data descriptors defined here:
__weakref__
list of weak references to the object (if defined)

Methods inherited from exceptions.Exception:
__init__(...)
x.__init__(...) initializes x; see help(type(x)) for signature

Data and other attributes inherited from exceptions.Exception:
__new__ = <built-in method __new__ of type object>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__str__(...)
x.__str__() <==> str(x)
__unicode__(...)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message

 
class HttpClient(__builtin__.object)
    Performs HTTP requests using httplib.
 
  Methods defined here:
Request = request(self, http_request)
request(self, http_request)

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Data and other attributes defined here:
debug = None

 
class HttpRequest(__builtin__.object)
    Contains all of the parameters for an HTTP 1.1 request.
 
The HTTP headers are represented by a dictionary, and it is the
responsibility of the user to ensure that duplicate field names are combined
into one header value according to the rules in section 4.2 of RFC 2616.
 
  Methods defined here:
AddBodyPart = add_body_part(self, data, mime_type, size=None)
AddFormInputs = add_form_inputs(self, form_data, mime_type='application/x-www-form-urlencoded')
__init__(self, uri=None, method=None, headers=None)
Construct an HTTP request.
 
Args:
  uri: The full path or partial path as a Uri object or a string.
  method: The HTTP method for the request, examples include 'GET', 'POST',
          etc.
  headers: dict of strings The HTTP headers to include in the request.
add_body_part(self, data, mime_type, size=None)
Adds data to the HTTP request body.
 
If more than one part is added, this is assumed to be a mime-multipart
request. This method is designed to create MIME 1.0 requests as specified
in RFC 1341.
 
Args:
  data: str or a file-like object containing a part of the request body.
  mime_type: str The MIME type describing the data
  size: int Required if the data is a file like object. If the data is a
        string, the size is calculated so this parameter is ignored.
add_form_inputs(self, form_data, mime_type='application/x-www-form-urlencoded')
Form-encodes and adds data to the request body.
 
Args:
  form_data: dict or sequnce or two member tuples which contains the
             form keys and values.
  mime_type: str The MIME type of the form data being sent. Defaults
             to 'application/x-www-form-urlencoded'.

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Data and other attributes defined here:
method = None
uri = None

 
class HttpResponse(__builtin__.object)
     Methods defined here:
__init__(self, status=None, reason=None, headers=None, body=None)
getheader(self, name, default=None)
getheaders(self)
read(self, amt=None)

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Data and other attributes defined here:
reason = None
status = None

 
class ProxiedHttpClient(HttpClient)
    
Method resolution order:
ProxiedHttpClient
HttpClient
__builtin__.object

Methods inherited from HttpClient:
Request = request(self, http_request)
request(self, http_request)

Data descriptors inherited from HttpClient:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Data and other attributes inherited from HttpClient:
debug = None

 
class ProxyError(Error)
    
Method resolution order:
ProxyError
Error
exceptions.Exception
exceptions.BaseException
__builtin__.object

Data descriptors inherited from Error:
__weakref__
list of weak references to the object (if defined)

Methods inherited from exceptions.Exception:
__init__(...)
x.__init__(...) initializes x; see help(type(x)) for signature

Data and other attributes inherited from exceptions.Exception:
__new__ = <built-in method __new__ of type object>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__str__(...)
x.__str__() <==> str(x)
__unicode__(...)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message

 
class UnknownSize(Error)
    
Method resolution order:
UnknownSize
Error
exceptions.Exception
exceptions.BaseException
__builtin__.object

Data descriptors inherited from Error:
__weakref__
list of weak references to the object (if defined)

Methods inherited from exceptions.Exception:
__init__(...)
x.__init__(...) initializes x; see help(type(x)) for signature

Data and other attributes inherited from exceptions.Exception:
__new__ = <built-in method __new__ of type object>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__str__(...)
x.__str__() <==> str(x)
__unicode__(...)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message

 
class Uri(__builtin__.object)
    A URI as used in HTTP 1.1
 
  Methods defined here:
ModifyRequest = modify_request(self, http_request=None)
__init__(self, scheme=None, host=None, port=None, path=None, query=None)
Constructor for a URI.
 
Args:
  scheme: str This is usually 'http' or 'https'.
  host: str The host name or IP address of the desired server.
  post: int The server's port number.
  path: str The path of the resource following the host. This begins with
        a /, example: '/calendar/feeds/default/allcalendars/full'
  query: dict of strings The URL query parameters. The keys and values are
         both escaped so this dict should contain the unescaped values.
         For example {'my key': 'val', 'second': '!!!'} will become
         '?my+key=val&second=%21%21%21' which is appended to the path.
__str__(self)
modify_request(self, http_request=None)
Sets HTTP request components based on the URI.

Static methods defined here:
ParseUri = parse_uri(uri_string)
Creates a Uri object which corresponds to the URI string.
 
This method can accept partial URIs, but it will leave missing
members of the Uri unset.
parse_uri(uri_string)
Creates a Uri object which corresponds to the URI string.
 
This method can accept partial URIs, but it will leave missing
members of the Uri unset.

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Data and other attributes defined here:
host = None
path = None
port = None
scheme = None

 
Functions
       
ParseUri = parse_uri(uri_string)
Creates a Uri object which corresponds to the URI string.
 
This method can accept partial URIs, but it will leave missing
members of the Uri unset.
get_headers(http_response)
Retrieves all HTTP headers from an HTTP response from the server.
 
This method is provided for backwards compatibility for Python2.2 and 2.3.
The httplib.HTTPResponse object in 2.2 and 2.3 does not have a getheaders
method so this function will use getheaders if available, but if not it
will retrieve a few using getheader.
parse_uri(uri_string)
Creates a Uri object which corresponds to the URI string.
 
This method can accept partial URIs, but it will leave missing
members of the Uri unset.

 
Data
        MIME_BOUNDARY = 'END_OF_PART'
__author__ = 'j.s@google.com (Jeff Scudder)'

 
Author
        j.s@google.com (Jeff Scudder)