Skip to content
Open
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 Tests/HttpFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public function testGetAvailableDriverDisallowsNonArrayObjects()
*/
public function testGetHttpTransports()
{
$transports = ['Stream', 'Socket', 'Curl'];
$transports = ['Stream', 'Curl'];
sort($transports);

$this->assertEquals(
Expand Down
11 changes: 0 additions & 11 deletions Tests/TransportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
namespace Joomla\Http\Tests;

use Joomla\Http\Transport\Curl;
use Joomla\Http\Transport\Socket;
use Joomla\Http\Transport\Stream;
use Joomla\Http\TransportInterface;
use Joomla\Uri\Uri;
Expand All @@ -33,7 +32,6 @@ class TransportTest extends TestCase
*/
protected $options = [
'transport.curl' => [CURLOPT_SSL_VERIFYPEER => false],
'transport.socket' => ['X-Joomla-Test: true'],
'transport.stream' => ['ignore_errors' => true],
];

Expand Down Expand Up @@ -70,7 +68,6 @@ public static function transportProvider(): array
{
return [
'curl adapter' => [Curl::class],
'socket adapter' => [Socket::class],
'stream adapter' => [Stream::class],
];
}
Expand All @@ -93,7 +90,6 @@ public static function relevantOnlyForStreamTransportProvider(): array
* @param string $transportClass The transport class to test
*
* @covers \Joomla\Http\Transport\Curl
* @covers \Joomla\Http\Transport\Socket
* @covers \Joomla\Http\Transport\Stream
* @uses \Joomla\Http\AbstractTransport
*/
Expand All @@ -116,7 +112,6 @@ public function testConstructorWithBadDataObject(string $transportClass)
* @param string $transportClass The transport class to test
*
* @covers \Joomla\Http\Transport\Curl
* @covers \Joomla\Http\Transport\Socket
* @covers \Joomla\Http\Transport\Stream
* @uses \Joomla\Http\AbstractTransport
*/
Expand Down Expand Up @@ -224,7 +219,6 @@ public function testRequestGetWhenBlockingModeIsDisabled(string $transportClass)
* @param string $transportClass The transport class to test
*
* @covers \Joomla\Http\Transport\Curl
* @covers \Joomla\Http\Transport\Socket
* @covers \Joomla\Http\Transport\Stream
* @uses \Joomla\Http\AbstractTransport
*/
Expand All @@ -249,7 +243,6 @@ public function testBadDomainRequestGet(string $transportClass)
* @param string $transportClass The transport class to test
*
* @covers \Joomla\Http\Transport\Curl
* @covers \Joomla\Http\Transport\Socket
* @covers \Joomla\Http\Transport\Stream
* @uses \Joomla\Http\AbstractTransport
*/
Expand Down Expand Up @@ -277,7 +270,6 @@ public function testRequestGet404(string $transportClass)
* @param string $transportClass The transport class to test
*
* @covers \Joomla\Http\Transport\Curl
* @covers \Joomla\Http\Transport\Socket
* @covers \Joomla\Http\Transport\Stream
* @uses \Joomla\Http\AbstractTransport
*/
Expand Down Expand Up @@ -312,7 +304,6 @@ public function testRequestPut(string $transportClass)
* @param string $transportClass The transport class to test
*
* @covers \Joomla\Http\Transport\Curl
* @covers \Joomla\Http\Transport\Socket
* @covers \Joomla\Http\Transport\Stream
* @uses \Joomla\Http\AbstractTransport
*/
Expand Down Expand Up @@ -356,7 +347,6 @@ public function testRequestCredentials(string $transportClass)
* @param string $transportClass The transport class to test
*
* @covers \Joomla\Http\Transport\Curl
* @covers \Joomla\Http\Transport\Socket
* @covers \Joomla\Http\Transport\Stream
* @uses \Joomla\Http\AbstractTransport
*/
Expand Down Expand Up @@ -396,7 +386,6 @@ public function testRequestPost(string $transportClass)
* @param string $transportClass The transport class to test
*
* @covers \Joomla\Http\Transport\Curl
* @covers \Joomla\Http\Transport\Socket
* @covers \Joomla\Http\Transport\Stream
* @uses \Joomla\Http\AbstractTransport
*/
Expand Down
6 changes: 1 addition & 5 deletions docs/classes/TransportInterface.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The contract every transport implements. `Http` holds one and delegates each request to it, so the
interface is the seam where you replace how requests are actually sent — with cURL, with a stream,
with a socket, or with a stub in tests.
or with a stub in tests.

## The interface

Expand Down Expand Up @@ -35,7 +35,6 @@ directly.
|---|---|---|
| `Transport\Curl` | `ext-curl` loaded | The default when available |
| `Transport\Stream` | `allow_url_fopen` enabled | Configurable TLS via a stream context |
| `Transport\Socket` | `fsockopen()` exists | Cannot be configured for TLS — see below |

`HttpFactory` picks one for you:

Expand All @@ -47,9 +46,6 @@ $http = (new HttpFactory())->getHttp([], 'curl'); // force one
$http = (new HttpFactory())->getHttp([], ['curl', 'stream']); // first supported of these
```

> Prefer `curl` or `stream`. `Socket` connects with `fsockopen()`, which accepts no stream context,
> so no CA bundle, minimum TLS version or client certificate can be supplied for it.

## Writing a transport

```php
Expand Down
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
* [Updating from v1 to v2](v1-to-v2-update.md)
* [Updating from v2 to v3](v2-to-v3-update.md)
* [Updating from v3 to v4](v3-to-v4-update.md)
* [Updating from v4 to v5](v4-to-v5-update.md)
5 changes: 0 additions & 5 deletions docs/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,6 @@ $http = (new HttpFactory())->getHttp([
so a large or hostile response can exhaust `memory_limit`. Fetch untrusted URLs with your own
limit in place.

**The socket transport cannot be configured for TLS.** It connects with `fsockopen()`, which takes
no stream context, so no CA bundle, minimum TLS version or client certificate can be supplied — and
the connection error is suppressed, so a certificate failure is indistinguishable from an
unreachable host. Prefer the cURL or stream transport.

**The stream transport accepts any wrapper.** The URI goes to `fopen()` unfiltered, so a `file://`,
`php://` or `phar://` URL is opened rather than rejected. Check the scheme before calling if the
URL is not your own.
Expand Down
43 changes: 43 additions & 0 deletions docs/v4-to-v5-update.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Updating from v4 to v5

Release 5.0.0 removes the socket transport, which was deprecated in 4.x.

## At a glance

| | v4 | v5 (5.0.0) |
|---|---|---|
| `Joomla\Http\Transport\Socket` | deprecated, works | **removed** |

## The socket transport was removed

`Joomla\Http\Transport\Socket` implemented HTTP/1.x by hand on top of `fsockopen()`. It could not be
configured for TLS (no CA bundle, minimum TLS version or client certificate), did not support
proxies and did not decode chunked responses. It was deprecated in 4.x, where creating it triggers
a deprecation notice, and is removed in 5.0.0.

`HttpFactory` now chooses between the cURL and the stream transport only. Code that names the
socket transport has to use one of the others:

```php
use Joomla\Http\HttpFactory;
use Joomla\Http\Transport\Stream;

// Removed in 5.0.0
$http = (new HttpFactory())->getHttp($options, 'socket');
$transport = new \Joomla\Http\Transport\Socket($options);

// Use the cURL or the stream transport
$http = (new HttpFactory())->getHttp($options, ['curl', 'stream']);
$transport = new Stream($options);
```

Asking the factory for `'socket'` alone now finds no transport: `getAvailableDriver()` returns
`false` and `getHttp()` throws a `RuntimeException`. The stream transport only needs
`allow_url_fopen`; options that were specific to the socket transport (`transport.socket`) have no
equivalent and can be dropped.

To find the call sites:

```bash
grep -rnE "Transport\\\\Socket|'socket'|transport\.socket" src/
```
Loading
Loading