HTTP Clients are object based on restclient.http.HTTPClient that perform HTPP operations.
You can choose the one you want as httpclient in Resource or RestClient:
from restclient.http import CurlHTTPClient
httpclient = CurlHTTPClient()
res = Resource(httpclient=httpclient)
Return the default http client instance instance if no client has been set, it will create a default client.
Returns: | the default client |
---|
Interface for HTTP clients
Perform HTTP call and manage , support GET, HEAD, POST, PUT and DELETE
Parameters: |
|
---|---|
Returns: | object representing HTTP Response |
HTTP Client that use urllib2. This module is included in python so i mean that you don’t need any dependancy to run this client and restclient.
urllib2 is very powerfull and you can use many handlers to manage authentification and proxies.
See also
Constructor for Urllib2HTTPClien
Parameters: |
|
---|
For example here is a way to have your urllib2 based client using http basic authentification :
password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
password_mgr.add_password(None, "%s/%s" % (self.url, "auth"),
"test", "test")
auth_handler = urllib2.HTTPBasicAuthHandler(password_mgr)
httpclient = Urllib2HTTPClient(auth_handler)
An HTTPClient that uses pycurl.
Pycurl is recommanded when you want fast access to http resources. We have added some basic management of authentification and proxies, but in case you want something specific you should use urllib2 or httplib2 http clients. Any patch is welcome though ;)
Here is an example to use authentification with curl httpclient :
httpclient = CurlHTTPClient()
httpclient.add_credentials("test", "test")
See also