Request and Response¶
-
class
dragline.http.
Request
(url, method=None, callback=None, meta=None, headers=None, files=None, data=None, json=None, params=None, auth=None, cookies=None, timeout=None, allow_redirects=None, proxies=None, stream=None, verify=None, cert=None, dont_filter=None)¶ Parameters: - url – URL to send.
- method – HTTP method to use.
- callback – name of the function to call after url is downloaded.
- meta – A dict that contains arbitrary metadata for this request.
- headers – dictionary of headers to send.
- files – dictionary of {filename: fileobject} files to multipart upload.
- data – the body to attach to the request. If a dictionary is provided, form-encoding will take place.
- json – json for the body to attach to the request (if data is not specified).
- params – dictionary of URL parameters to append to the URL.
- auth – Auth handler or (user, pass) tuple.
- cookies – dictionary or CookieJar of cookies to attach to this request.
- timeout (float or tuple) – (optional) How long to wait for the server to send data before giving up, as a float, or a tuple.
- allow_redirects (bool) – (optional) Set to True by default.
- proxies – (optional) Dictionary mapping protocol to the URL of the proxy.
- stream – (optional) whether to immediately download the response
content. Defaults to
False
. - verify – (optional) if
True
, the SSL cert will be verified. A CA_BUNDLE path can also be provided. - cert – (optional) if String, path to ssl client cert file (.pem). If Tuple, (‘cert’, ‘key’) pair.
-
send
()¶ This function sends HTTP requests.
Returns: response Return type: dragline.http.Response
Raises: dragline.http.RequestError
: when failed to fetch contents>>> req = Request("http://www.example.org") >>> response = req.send() >>> print response.headers['status'] 200