Package restkit :: Module client :: Class Client
[hide private]
[frames] | no frames]

Class Client

source code

object --+
         |
        Client

A client handle a connection at a time. A client is threadsafe,
    but an handled shouldn't be shared between threads. All connections
    are shared between threads via a pool. 
    
    >>> from restkit import *
    >>> c = Client()
    >>> c.url = "http://google.com"
    >>> r = c.perform()
    r>>> r.status
    '301 Moved Permanently'
    >>> r.body_string()
    '<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>
'
    >>> c.follow_redirect = True
    >>> r = c.perform()
    >>> r.status
    '200 OK'
     
    

Nested Classes [hide private]
  response_class
Instance Methods [hide private]
 
__init__(self, follow_redirect=False, force_follow_redirect=False, max_follow_redirect=5, filters=None, decompress=True, manager=None, response_class=None, timeout=300, force_dns=False, max_tries=5, wait_tries=1.0, **ssl_args)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
_headers__get(self) source code
 
_headers__set(self, value) source code
 
_host__get(self) source code
 
_parsed_url__get(self) source code
 
_path__get(self) source code
 
_url__get(self) source code
 
_url__set(self, string) source code
 
close_connection(self)
close a connection
source code
 
connect(self, addr, ssl)
create a socket
source code
 
get_connection(self)
get a connection from the pool or create new one.
source code
 
get_response(self)
return final respons, it is only accessible via peform method
source code
 
make_headers_string(self)
create final header string
source code
 
parse_body(self)
transform a body if needed and set appropriate headers
source code
 
perform(self)
perform the request.
source code
 
redirect(self, resp, location, method=None)
reset request, set new url of request and perform it
source code
 
release_connection(self, key, sck, should_close=False)
release a connection to the pool
source code
 
req_is_chunked(self) source code
 
req_is_ssl(self) source code
 
request(self, url, method='GET', body=None, headers=None)
perform immediatly a new request
source code
 
reset_request(self)
reset a client handle to its intial state before performing.
source code
 
write_callback(self, cb) source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  version = (1, 1)
Properties [hide private]
  headers
  host
  parsed_url
  path
request path
  url
current url to request

Inherited from object: __class__

Method Details [hide private]

__init__(self, follow_redirect=False, force_follow_redirect=False, max_follow_redirect=5, filters=None, decompress=True, manager=None, response_class=None, timeout=300, force_dns=False, max_tries=5, wait_tries=1.0, **ssl_args)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

perform(self)

source code 

perform the request. If an error happen it will first try to restart it

reset_request(self)

source code 

reset a client handle to its intial state before performing. It doesn't handle case where body has already been consumed


Property Details [hide private]

headers

Get Method:
_headers__get(self)
Set Method:
_headers__set(self, value)

host

Get Method:
_host__get(self)

parsed_url

Get Method:
_parsed_url__get(self)

path

request path

Get Method:
_path__get(self)

url

current url to request

Get Method:
_url__get(self)
Set Method:
_url__set(self, string)