Skip to content

Commit a99398f

Browse files
authored
[6.0] Deprecate Http CMS package (#45751)
* HTTP Response: Moving b/c getter from framework to CMS * Deprecate CMS Http package. Use framework instead * Remove deprecated calls to Http CMS package * Codestyle * More fixes * Revert change
1 parent fbe4f77 commit a99398f

File tree

7 files changed

+92
-11
lines changed

7 files changed

+92
-11
lines changed

libraries/src/Http/Http.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
* HTTP client class.
2121
*
2222
* @since 1.7.3
23+
* @deprecated __DEPLOY_VERSION__ will be removed in 7.0
24+
* Use Joomla\Http\Http instead
2325
*/
2426
class Http extends FrameworkHttp
2527
{
@@ -30,8 +32,10 @@ class Http extends FrameworkHttp
3032
* these will be added to the request headers.
3133
* @param ?FrameworkTransportInterface $transport The HTTP transport object.
3234
*
33-
* @since 1.7.3
3435
* @throws \InvalidArgumentException
36+
* @since 1.7.3
37+
* @deprecated __DEPLOY_VERSION__ will be removed in 7.0
38+
* Use Joomla\Http\Http::__construct() instead
3539
*/
3640
public function __construct($options = [], ?FrameworkTransportInterface $transport = null)
3741
{

libraries/src/Http/HttpFactory.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
* HTTP factory class.
2121
*
2222
* @since 3.0.0
23+
* @deprecated __DEPLOY_VERSION__ will be removed in 7.0
24+
* Use Joomla\Http\HttpFactory instead
2325
*/
2426
class HttpFactory
2527
{
@@ -31,8 +33,10 @@ class HttpFactory
3133
*
3234
* @return Http
3335
*
34-
* @since 3.0.0
3536
* @throws \RuntimeException
37+
* @since 3.0.0
38+
* @deprecated __DEPLOY_VERSION__ will be removed in 7.0
39+
* Use Joomla\Http\HttpFactory::getHttp() instead
3640
*/
3741
public static function getHttp($options = [], $adapters = null)
3842
{
@@ -64,6 +68,8 @@ public static function getHttp($options = [], $adapters = null)
6468
* @return TransportInterface|boolean Interface sub-class or boolean false if no adapters are available
6569
*
6670
* @since 3.0.0
71+
* @deprecated __DEPLOY_VERSION__ will be removed in 7.0
72+
* Use Joomla\Http\HttpFactory::getAvailableDriver() instead
6773
*/
6874
public static function getAvailableDriver($options = [], $default = null)
6975
{
@@ -101,6 +107,8 @@ public static function getAvailableDriver($options = [], $default = null)
101107
* @return array An array of available transport handlers
102108
*
103109
* @since 3.0.0
110+
* @deprecated __DEPLOY_VERSION__ will be removed in 7.0
111+
* Use Joomla\Http\HttpFactory::getHttpTransports() instead
104112
*/
105113
public static function getHttpTransports()
106114
{

libraries/src/Http/Response.php

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,50 @@
2020
*
2121
* @since 1.7.3
2222
*
23-
* @deprecated 4.0 will be removed in 6.0
23+
* @deprecated 4.0 will be removed in 7.0
2424
* Use Joomla\Http\Response instead
2525
*/
2626
class Response extends FrameworkResponse
2727
{
28+
/**
29+
* Magic getter for backward compatibility with the 1.x Joomla Framework API
30+
*
31+
* @param string $name The variable to return
32+
*
33+
* @return mixed
34+
*
35+
* @since __DEPLOY_VERSION__
36+
* @deprecated __DEPLOY_VERSION__ will be removed in 7.0
37+
* Access data via the PSR-7 ResponseInterface instead
38+
*/
39+
public function __get($name)
40+
{
41+
switch (strtolower($name)) {
42+
case 'body':
43+
$stream = $this->getBody();
44+
$stream->rewind();
45+
return $stream->getContents();
46+
47+
case 'code':
48+
return $this->getStatusCode();
49+
50+
case 'headers':
51+
return $this->getHeaders();
52+
53+
default:
54+
$trace = debug_backtrace();
55+
56+
trigger_error(
57+
\sprintf(
58+
'Undefined property via __get(): %s in %s on line %s',
59+
$name,
60+
$trace[0]['file'],
61+
$trace[0]['line']
62+
),
63+
E_USER_NOTICE
64+
);
65+
66+
break;
67+
}
68+
}
2869
}

libraries/src/Http/Transport/CurlTransport.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
* HTTP transport class for using cURL.
2828
*
2929
* @since 1.7.3
30+
* @deprecated __DEPLOY_VERSION__ will be removed in 7.0
31+
* Use Joomla\Http\Transport\Curl instead
3032
*/
3133
class CurlTransport extends AbstractTransport implements TransportInterface
3234
{
@@ -42,8 +44,10 @@ class CurlTransport extends AbstractTransport implements TransportInterface
4244
*
4345
* @return Response
4446
*
45-
* @since 1.7.3
4647
* @throws \RuntimeException
48+
* @since 1.7.3
49+
* @deprecated __DEPLOY_VERSION__ will be removed in 7.0
50+
* Use Joomla\Http\Transport\Curl::request() instead
4751
*/
4852
public function request($method, UriInterface $uri, $data = null, array $headers = [], $timeout = null, $userAgent = null)
4953
{
@@ -211,8 +215,10 @@ public function request($method, UriInterface $uri, $data = null, array $headers
211215
*
212216
* @return Response
213217
*
214-
* @since 1.7.3
215218
* @throws InvalidResponseCodeException
219+
* @since 1.7.3
220+
* @deprecated __DEPLOY_VERSION__ will be removed in 7.0
221+
* Use Joomla\Http\Transport\Curl::getResponse() instead
216222
*/
217223
protected function getResponse($content, $info)
218224
{
@@ -270,6 +276,8 @@ protected function getResponse($content, $info)
270276
* @return boolean true if available, else false
271277
*
272278
* @since 3.0.0
279+
* @deprecated __DEPLOY_VERSION__ will be removed in 7.0
280+
* Use Joomla\Http\Transport\Curl::isSupported() instead
273281
*/
274282
public static function isSupported()
275283
{
@@ -282,6 +290,8 @@ public static function isSupported()
282290
* @return boolean
283291
*
284292
* @since 3.0.0
293+
* @deprecated __DEPLOY_VERSION__ will be removed in 7.0
294+
* Use Joomla\Http\Transport\Curl::redirectsAllowed() instead
285295
*/
286296
private function redirectsAllowed()
287297
{

libraries/src/Http/Transport/SocketTransport.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
* HTTP transport class for using sockets directly.
2727
*
2828
* @since 1.7.3
29+
* @deprecated __DEPLOY_VERSION__ will be removed in 7.0
30+
* Use Joomla\Http\Transport\Socket instead
2931
*/
3032
class SocketTransport extends AbstractTransport implements TransportInterface
3133
{
@@ -47,8 +49,10 @@ class SocketTransport extends AbstractTransport implements TransportInterface
4749
*
4850
* @return Response
4951
*
50-
* @since 1.7.3
5152
* @throws \RuntimeException
53+
* @since 1.7.3
54+
* @deprecated __DEPLOY_VERSION__ will be removed in 7.0
55+
* Use Joomla\Http\Transport\Socket::request() instead
5256
*/
5357
public function request($method, UriInterface $uri, $data = null, array $headers = [], $timeout = null, $userAgent = null)
5458
{
@@ -144,8 +148,10 @@ public function request($method, UriInterface $uri, $data = null, array $headers
144148
*
145149
* @return Response
146150
*
147-
* @since 1.7.3
148151
* @throws InvalidResponseCodeException
152+
* @since 1.7.3
153+
* @deprecated __DEPLOY_VERSION__ will be removed in 7.0
154+
* Use Joomla\Http\Transport\Socket::getResponse() instead
149155
*/
150156
protected function getResponse($content)
151157
{
@@ -188,8 +194,10 @@ protected function getResponse($content)
188194
*
189195
* @return resource Socket connection resource.
190196
*
191-
* @since 1.7.3
192197
* @throws \RuntimeException
198+
* @since 1.7.3
199+
* @deprecated __DEPLOY_VERSION__ will be removed in 7.0
200+
* Use Joomla\Http\Transport\Socket::connect() instead
193201
*/
194202
protected function connect(UriInterface $uri, $timeout = null)
195203
{
@@ -270,6 +278,8 @@ protected function connect(UriInterface $uri, $timeout = null)
270278
* @return boolean True if available else false
271279
*
272280
* @since 3.0.0
281+
* @deprecated __DEPLOY_VERSION__ will be removed in 7.0
282+
* Use Joomla\Http\Transport\Socket::isSupported() instead
273283
*/
274284
public static function isSupported()
275285
{

libraries/src/Http/Transport/StreamTransport.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
* HTTP transport class for using PHP streams.
2828
*
2929
* @since 1.7.3
30+
* @deprecated __DEPLOY_VERSION__ will be removed in 7.0
31+
* Use Joomla\Http\Transport\Stream instead
3032
*/
3133
class StreamTransport extends AbstractTransport implements TransportInterface
3234
{
@@ -42,8 +44,10 @@ class StreamTransport extends AbstractTransport implements TransportInterface
4244
*
4345
* @return Response
4446
*
45-
* @since 1.7.3
4647
* @throws \RuntimeException
48+
* @since 1.7.3
49+
* @deprecated __DEPLOY_VERSION__ will be removed in 7.0
50+
* Use Joomla\Http\Transport\Stream::request() instead
4751
*/
4852
public function request($method, UriInterface $uri, $data = null, array $headers = [], $timeout = null, $userAgent = null)
4953
{
@@ -190,8 +194,10 @@ public function request($method, UriInterface $uri, $data = null, array $headers
190194
*
191195
* @return Response
192196
*
193-
* @since 1.7.3
194197
* @throws InvalidResponseCodeException
198+
* @since 1.7.3
199+
* @deprecated __DEPLOY_VERSION__ will be removed in 7.0
200+
* Use Joomla\Http\Transport\Stream::getResponse() instead
195201
*/
196202
protected function getResponse(array $headers, $body)
197203
{
@@ -219,6 +225,8 @@ protected function getResponse(array $headers, $body)
219225
* @return boolean true if available else false
220226
*
221227
* @since 3.0.0
228+
* @deprecated __DEPLOY_VERSION__ will be removed in 7.0
229+
* Use Joomla\Http\Transport\Stream::isSupported() instead
222230
*/
223231
public static function isSupported()
224232
{

libraries/src/Http/TransportInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*
2121
* @since 1.7.3
2222
*
23-
* @deprecated 4.0 will be removed in 6.0
23+
* @deprecated 4.0 will be removed in 7.0
2424
* Implement Joomla\Http\TransportInterface instead
2525
*/
2626
interface TransportInterface extends FrameworkTransportInterface

0 commit comments

Comments
 (0)