Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"description" : "HTTP protocol support for the XP Framework",
"keywords": ["module", "xp"],
"require" : {
"xp-framework/core": "^12.0 | ^11.0 | ^10.0",
"xp-framework/core": "^12.11 | ^11.11",
"xp-framework/logging": "^11.0 | ^10.0",
"xp-framework/networking": "^11.0 | ^10.0 | ^9.3",
"php" : ">=7.4.0"
Expand Down
12 changes: 6 additions & 6 deletions src/main/php/peer/http/CurlHttpTransport.class.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php namespace peer\http;

use io\IOException;
use io\OperationFailed;
use io\streams\MemoryInputStream;
use peer\URL;

Expand Down Expand Up @@ -32,7 +32,7 @@ public function __construct(URL $url, $arg) {
* @param float $connectTimeout default 2.0
* @param float $readTimeout default 60.0
* @return peer.http.HttpOutputStream
* @throws io.IOException
* @throws io.OperationFailed
*/
public function open(HttpRequest $request, $connectTimeout= 2.0, $readTimeout= 60.0) {
static $versions= [
Expand Down Expand Up @@ -85,7 +85,7 @@ public function open(HttpRequest $request, $connectTimeout= 2.0, $readTimeout= 6
*
* @param peer.http.HttpOutputStream $stream
* @return peer.http.HttpResponse
* @throws io.IOException
* @throws io.OperationFailed
*/
public function finish($stream) {
$stream->close();
Expand All @@ -98,7 +98,7 @@ public function finish($stream) {
$error= curl_errno($stream->handle);
$message= curl_error($stream->handle);
curl_close($stream->handle);
throw new IOException($error.' '.$message);
throw new OperationFailed($error.' '.$message);
}

// Strip "HTTP/x.x 200 Connection established" which is followed by
Expand All @@ -120,7 +120,7 @@ public function finish($stream) {
* @param int $timeout default 60
* @param float $connecttimeout default 2.0
* @return peer.http.HttpResponse response object
* @throws io.IOException
* @throws io.OperationFailed
*/
public function send(HttpRequest $request, $timeout= 60, $connecttimeout= 2.0) {
static $versions= [
Expand Down Expand Up @@ -176,7 +176,7 @@ public function send(HttpRequest $request, $timeout= 60, $connecttimeout= 2.0) {
$errno= curl_errno($handle);
$error= curl_error($handle);
curl_close($handle);
throw new \io\IOException(sprintf('%d: %s', $errno, $error));
throw new \io\OperationFailed(sprintf('%d: %s', $errno, $error));
}
// ensure handle is closed
curl_close($handle);
Expand Down
2 changes: 1 addition & 1 deletion src/main/php/peer/http/HttpConnection.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public function create(HttpRequest $r) {
* @param var $parameters
* @param [:string] $headers default array()
* @return peer.http.HttpResponse response object
* @throws io.IOException
* @throws io.OperationFailed
*/
public function request($method, $parameters= null, $headers= []) {
$r= new HttpRequest($this->url);
Expand Down
2 changes: 1 addition & 1 deletion src/main/php/peer/http/HttpResponse.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public function readData($size= 8192) {
if (!($indicator= $this->scanUntil("\n"))) return $this->closeStream();
if (!(sscanf($indicator, "%x%s\r", $chunksize, $extension))) {
$this->closeStream();
throw new \io\IOException(sprintf(
throw new \io\OperationFailed(sprintf(
'Chunked transfer encoding: Indicator line "%s" invalid',
addcslashes($indicator, "\0..\17")
));
Expand Down
10 changes: 5 additions & 5 deletions src/main/php/peer/http/SSLSocketHttpTransport.class.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php namespace peer\http;

use io\IOException;
use io\OperationFailed;
use peer\{CryptoSocket, URL};
use util\Objects;

Expand Down Expand Up @@ -56,7 +56,7 @@ protected function newSocket(URL $url, $arg) {
* @param peer.http.HttpRequest $request
* @param peer.URL $url
* @return void
* @throws io.IOException
* @throws io.OperationFailed
*/
protected function proxy($s, $request, $url) {
$connect= sprintf(
Expand All @@ -70,14 +70,14 @@ protected function proxy($s, $request, $url) {
// Verify we are actually talking to a HTTP proxy
$handshake= $s->read();
if (4 !== ($r= sscanf($handshake, "HTTP/%*d.%*d %d %[^\r]", $status, $message))) {
throw new IOException('Proxy did not answer with valid HTTP: '.$handshake);
throw new OperationFailed('Proxy did not answer with valid HTTP: '.$handshake);
}

// Verify proxy answers with a 200 status code
while ($line= $s->readLine()) $handshake.= $line."\n";
$this->cat && $this->cat->info('<<<', $handshake);
if (200 !== $status) {
throw new IOException('Cannot connect through proxy: #'.$status.' '.$message);
throw new OperationFailed('Cannot connect through proxy: #'.$status.' '.$message);
}

// Enable cryptography
Expand All @@ -87,7 +87,7 @@ protected function proxy($s, $request, $url) {
foreach (self::$crypto as $name => $flag) {
if ($flag === $this->socket->cryptoImpl & $flag) $methods.= ', '.$name;
}
throw new IOException('Cannot establish secure connection, tried '.substr($methods, 2));
throw new OperationFailed('Cannot establish secure connection, tried '.substr($methods, 2));
}

$this->cat && $this->cat->debug('@@@ Enabled cryptography: '.Objects::stringOf(stream_get_meta_data($s->getHandle())['crypto']));
Expand Down
Loading