Package httxlib :: Module httxresponse
[hide private]
[frames] | no frames]

Module httxresponse

source code

This module implements a series of hacks to the HTTPResponse class to enable extra functionaliy (and practical in some cases) for the HttxLib

Rather than creating a new class and given that HTTPResponse is already well suited for usage in CookieJars (except for the missing info method), extending the class seems suitable.

Subclassing is not possible, because the HTTPResponse is instantiated inside httplib.

Creating a class and instantiating it out of the data stored in the HTTPResponse would be possible but data would have to be copied for each response.

This alternative seems the better: patching the class definition at the start of the program and therefore be able to use the instantiated HTTPResponse everywhere

Functions [hide private]
 
httxinit(self, sock, debuglevel=0, strict=0, method=None)
It replaces the HTTPResponse.__init__ to allow to add and initialize a member variable at object instantiation
source code
bool
httxredirecting_or_authenticating(self)
Utility function to check if a response is underdoing a redirection or authentication and network activity is pending redirection or a CONNECT tunnel has been initiated
source code
bool
httxisredir(self)
Utility function to check if a response is requesting redirection
source code
bool
httxisredirget(self)
Utility function to check if the redir codes are good for a GET request
source code
bool
httxisredirpost(self)
Utility function to check if the redir codes are good for a POST request
source code
bool
httxisredirpostrfc2616(self)
Utility function to check if the redir codes are good for a POST request according to RFC 2616
source code
bool
httxisauth(self)
Utility function to check if a response is requesting authentication
source code
bool
httxredirecting(self)
Utility function to check if a response indicates that pending network activity exists, because a new request has been isssued following a redirect request
source code
bool
httxauthenticating(self)
Utility function to check if a response indicates that pending network activity exists, because a new request has been isssued following an authentication request
source code
bool
httxisauthuser(self)
Utility function to check if the requested authentication is www-authenticate
source code
bool
httxisauthproxy(self)
Utility function to check if the requested authentication is proxy-authenticate
source code
HTTPMessage
httxinfo(self)
Utility function to make HTTPResponse fully compatible with CookieJar requirements
source code
 
httxbegin(self)
Wrapper for HTTPResponse.begin to allow for the body to be read and leave the connection free for further re-use
source code
str
httxread(self, amt=None)
Wrapper for HTTPResponse.read to read the body contents from the StringIO object created during httxbegin connection free for further re-use
source code
str
httxgetbody(self)
Utility function for a property get descriptor for body
source code
 
httxsetbody(self, value)
Utility function for a property set descriptor for body
source code
 
httxgetbodyfile(self)
Utility function for a property tet descriptor for bodyfile
source code
list
_httxgetheaderlist(self, name)
return a list of all header returned with the same name (www-authenticate is an example)
source code
Variables [hide private]
  __package__ = 'httxlib'
Function Details [hide private]

httxinit(self, sock, debuglevel=0, strict=0, method=None)

source code 

It replaces the HTTPResponse.__init__ to allow to add and initialize a member variable at object instantiation

Sock is the opaque type (actually a Python sock object) used in HttxLib to index connecting objects with pending network activity

httxredirecting_or_authenticating(self)

source code 

Utility function to check if a response is underdoing a redirection or authentication and network activity is pending redirection or a CONNECT tunnel has been initiated

Returns: bool
if the response is underdoing a redirection or authentication and network activity is pending

httxisredir(self)

source code 

Utility function to check if a response is requesting redirection

Returns: bool
if the response is a request to redirect

httxisredirget(self)

source code 

Utility function to check if the redir codes are good for a GET request

Returns: bool
if the redir codes are good for a GET request

httxisredirpost(self)

source code 

Utility function to check if the redir codes are good for a POST request

Returns: bool
if the redir codes are good for a POST request

httxisredirpostrfc2616(self)

source code 

Utility function to check if the redir codes are good for a POST request according to RFC 2616

Returns: bool
if the redir codes are good for a POST request according to RFC 2616

httxisauth(self)

source code 

Utility function to check if a response is requesting authentication

Returns: bool
if a response is requesting authentication

httxredirecting(self)

source code 

Utility function to check if a response indicates that pending network activity exists, because a new request has been isssued following a redirect request

Returns: bool
if a response is undergoing network activity because a redirection request has been sent

httxauthenticating(self)

source code 

Utility function to check if a response indicates that pending network activity exists, because a new request has been isssued following an authentication request

Returns: bool
if a response is undergoing network activity because an authentication request has been sent

httxisauthuser(self)

source code 

Utility function to check if the requested authentication is www-authenticate

Returns: bool
if the requested authentication is www-authenticate

httxisauthproxy(self)

source code 

Utility function to check if the requested authentication is proxy-authenticate

Returns: bool
if the requested authentication is proxy-authenticate

httxinfo(self)

source code 

Utility function to make HTTPResponse fully compatible with CookieJar requirements

Returns: HTTPMessage
the message object from HTTPResponse

httxread(self, amt=None)

source code 

Wrapper for HTTPResponse.read to read the body contents from the StringIO object created during httxbegin connection free for further re-use

Parameters:
  • amt (int or None) - amount of bytes to be read
Returns: str
the read bytes

httxgetbody(self)

source code 

Utility function for a property get descriptor for body

Returns: str
the body of the http response

httxsetbody(self, value)

source code 

Utility function for a property set descriptor for body

Parameters:
  • value (str) - the body of the http response to set

_httxgetheaderlist(self, name)

source code 

return a list of all header returned with the same name (www-authenticate is an example)

Parameters:
  • name (str) - name of the header
Returns: list
a list of the values sent for the header