xp-framework / http
HTTP protocol support for the XP Framework
Installs: 98 861
Dependents: 11
Suggesters: 0
Security: 0
Stars: 2
Watchers: 4
Forks: 2
Open Issues: 6
Requires
- php: >=7.0.0
- xp-framework/core: ^12.0 | ^11.0 | ^10.0 | ^9.0 | ^8.0 | ^7.0 | ^6.5
- xp-framework/logging: ^11.0 | ^10.0 | ^9.0 | ^8.0 | ^7.0 | ^6.5
- xp-framework/networking: ^10.0 | ^9.0 | ^8.0 | ^7.0 | ^6.6
Requires (Dev)
- xp-framework/test: ^2.0 | ^1.0
Suggests
- ext-curl: Alternative to ext-openssl for SSL-/TLS connections
- ext-openssl: Allows to use SSL/TLS, e.g. for https-connections
- dev-master
- v10.3.0
- v10.2.0
- v10.1.0
- v10.0.3
- v10.0.2
- v10.0.1
- v10.0.0
- v9.1.4
- v9.1.3
- v9.1.2
- v9.1.1
- v9.1.0
- v9.0.3
- v9.0.2
- v9.0.1
- v9.0.0
- v8.0.1
- v8.0.0
- v7.0.1
- v7.0.0
- v6.2.1
- v6.2.0
- v6.1.3
- v6.1.2
- v6.1.1
- v6.1.0
- v6.0.1
- v6.0.0
- dev-feature/keep-alive
- dev-feature/accept-paths
- dev-fix/http-delete
- dev-feature/digest-auth-squash
- dev-feature/digest-auth
This package is auto-updated.
Last update: 2024-12-24 13:34:49 UTC
README
Implements HTTP (HyperText Transfer Protocol) and provides a client to interact with HTTP servers. The HttpConnection
is the entry point class.
Methods
Different request methods are handled by HttpConnection
class methods as follows:
- GET - via
get()
- POST - via
post()
- HEAD - via
head()
- PUT - via
put()
- PATCH - via
patch()
- DELETE - via
delete()
- OPTIONS - via
options()
- TRACE - via
trace()
Other methods (e.g. MKCOL
from WebDAV) are supported via request()
.
Headers
The following code will show the response headers for a HEAD request:
use peer\http\HttpConnection; $c= new HttpConnection('http://xp-framework.net/'); Console::writeLine($c->head());
Getting data
with ($c= new HttpConnection('http://xp-framework.net/')); { $response= $c->get(); Console::writeLine('Response: ', $response); $in= $response->in(); while ($in->available()) { $bytes= $in->read(); } }
SSL support
This API also supports SSL connections - based on the scheme given to HttpConnection
's constructor the HttpRequestFactory
class will create an SSL connection. This is transparent from the outside, the rest of the calls are the same!
Example:
$c= new HttpConnection('https://example.com/');
Note: SSL connections depend on either the PHP extension curl
or openssl
.