Download the PHP package comodojo/httprequest without Composer
On this page you can find all versions of the php package comodojo/httprequest. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package httprequest
comodojo/httprequest
HTTP request library
This is the development branch, please do not use it in production
Main features:
- BASIC, NTLM, DIGEST and SPNEGO auth (requires php curl library) authentication support
- proxy support
- allowed http methods: GET, POST, PUT, DELETE
- CURL or stream working mode
- request customization (useragent, http version, content type, ...)
Installation
Install composer, then:
composer require comodojo/httprequest
Basic usage
Library usage is trivial: first create an instance of Httprequest specifing remote host address, then use get
or send
method to start request. It's important to wrap code in a try/catch block to handle exceptions (if any).
Constructor accepts two parameters: remote host address (required) and a boolean value (optional) that, if false, will force lib to use streams instead of curl.
-
Using get:
- Using send:
Class setters (chainable methods)
-
Set destination port (default 80)
-
Set timeout (in secs)
-
Set a custom user agent (default to 'Comodojo-Httprequest')
-
Set HTTP version (1.0 or 1.1)
-
Set content type (default to 'application/x-www-form-urlencoded' and used only with
send
method) -
Set additional/custom headers:
-
Set authentication:
-
Set proxy:
-
Ignore errors (stream only):
Force the stream to ignore errors and to return http code and content from the server instead of throwing an exception.
Class getters
-
Get response headers:
- Get HTTP received status code:
Multiple requests
The reset
method helps resetting options and data channel; for example:
Documentation
Contributing
Contributions are welcome and will be fully credited. Please see CONTRIBUTING for details.
License
comodojo/httprequest
is released under the MIT License (MIT). Please see License File for more information.