-
-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This also drops support for header lines delimited with \n instead of \r\n.
- Loading branch information
Showing
15 changed files
with
664 additions
and
751 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
namespace Amp\Http\Client\Internal; | ||
|
||
use Amp\CancellationToken; | ||
use Amp\Failure; | ||
use Amp\Http\Client\Client; | ||
use Amp\Http\Client\HttpException; | ||
use Amp\Http\Client\NetworkInterceptor; | ||
use Amp\Http\Client\Request; | ||
use Amp\Promise; | ||
use function Amp\call; | ||
|
||
class CallableNetworkClient implements Client | ||
{ | ||
private $callable; | ||
|
||
public function __construct(callable $callable) | ||
{ | ||
$this->callable = $callable; | ||
} | ||
|
||
public function request(Request $request, CancellationToken $cancellation = null): Promise | ||
{ | ||
$callable = $this->callable; | ||
$this->callable = null; | ||
|
||
if ($callable === null) { | ||
return new Failure(new HttpException(__METHOD__ . ' may only be invoked once per instance. ' | ||
. 'If you need to implement retries or otherwise issue multiple requests, register an ApplicationInterceptor to do so.')); | ||
} | ||
|
||
return call($callable); | ||
} | ||
|
||
public function addNetworkInterceptor(NetworkInterceptor $networkInterceptor): void | ||
{ | ||
throw new \RuntimeException('Operation not supported'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.