atom.http_core
index
/usr/local/svn/gdata-python-client/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
urllib
urlparse

 
Classes
       
__builtin__.object
HttpClient
HttpRequest
HttpResponse
Uri
exceptions.Exception(exceptions.BaseException)
Error
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 x.__class__.__doc__ for signature

Data and other attributes inherited from exceptions.Exception:
__new__ = <built-in method __new__ of type object at 0x722d20>
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)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message
exception 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, scheme=None, host=None, port=None, method=None, uri=None, headers=None)
Construct an HTTP request.
 
Args:
  scheme: str The protocol to be used, usually this is 'http' or 'https'
  host: str The name or IP address string of the server.
  port: int The port number to connect to on the server.
  method: The HTTP method for the request, examples include 'GET', 'POST',
          etc.
  uri: str The relative path inclusing escaped query parameters.
  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')

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
method = None
port = None
scheme = 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)
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 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 x.__class__.__doc__ for signature

Data and other attributes inherited from exceptions.Exception:
__new__ = <built-in method __new__ of type object at 0x722d20>
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)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message
exception 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'.
  ... TODO
  query: dict of strings The URL query parameters. The keys and values are
         both escaped so this dict should contain the unescaped values.
modify_request(self, http_request=None)
Sets HTTP request components based on the URI.

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.
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)