Skip to content

Commit b5683e8

Browse files
author
Oleksandr Iegorov
committed
Fix for issue #21299. Change HEAD action mapping to GET action interface and add HEAD request handling
1 parent 2a337f9 commit b5683e8

File tree

3 files changed

+21
-20
lines changed

3 files changed

+21
-20
lines changed

lib/internal/Magento/Framework/App/Test/Unit/HttpTest.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -181,13 +181,9 @@ public function testLaunchException()
181181
$this->setUpLaunch();
182182
$this->frontControllerMock->expects($this->once())
183183
->method('dispatch')
184-
->with($this->requestMock)->will(
185-
$this->returnCallback(
186-
function () {
187-
// phpcs:ignore Magento2.Exceptions.DirectThrow
188-
throw new \Exception('Message');
189-
}
190-
)
184+
->with($this->requestMock)
185+
->willThrowException(
186+
new \Exception('Message')
191187
);
192188
$this->http->launch();
193189
}

lib/internal/Magento/Framework/File/Test/Unit/Transfer/Adapter/HttpTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ public function testSend(): void
7373
$this->mime->expects($this->once())
7474
->method('getMimeType')
7575
->with($file)
76-
->will($this->returnValue($contentType));
76+
->willReturn($contentType);
7777
$this->request->expects($this->once())
7878
->method('isHead')
79-
->will($this->returnValue(false));
79+
->willReturn(false);
8080
$this->expectOutputString(file_get_contents($file));
8181

8282
$this->object->send($file);

lib/internal/Magento/Framework/File/Transfer/Adapter/Http.php

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,40 +6,45 @@
66

77
namespace Magento\Framework\File\Transfer\Adapter;
88

9+
use Magento\Framework\HTTP\PhpEnvironment\Response;
10+
use Magento\Framework\File\Mime;
11+
use Magento\Framework\App\Request\Http as HttpRequest;
12+
use Magento\Framework\App\ObjectManager;
13+
914
/**
1015
* File adapter to send the file to the client.
1116
*/
1217
class Http
1318
{
1419
/**
15-
* @var \Magento\Framework\HTTP\PhpEnvironment\Response
20+
* @var Response
1621
*/
1722
private $response;
1823

1924
/**
20-
* @var \Magento\Framework\File\Mime
25+
* @var Mime
2126
*/
2227
private $mime;
2328

2429
/**
25-
* @var \Magento\Framework\App\Request\Http
30+
* @var HttpRequest
2631
*/
2732
private $request;
2833

2934
/**
30-
* @param \Magento\Framework\HTTP\PhpEnvironment\Response $response
31-
* @param \Magento\Framework\File\Mime $mime
32-
* @param \Magento\Framework\App\Request\Http|null $request
35+
* @param Response $response
36+
* @param Mime $mime
37+
* @param HttpRequest|null $request
3338
*/
3439
public function __construct(
35-
\Magento\Framework\HTTP\PhpEnvironment\Response $response,
36-
\Magento\Framework\File\Mime $mime,
37-
\Magento\Framework\App\Request\Http $request = null
40+
Response $response,
41+
Mime $mime,
42+
HttpRequest $request = null
3843
) {
3944
$this->response = $response;
4045
$this->mime = $mime;
41-
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
42-
$this->request = $request ?: $objectManager->get(\Magento\Framework\App\Request\Http::class);
46+
$objectManager = ObjectManager::getInstance();
47+
$this->request = $request ?: $objectManager->get(HttpRequest::class);
4348
}
4449

4550
/**

0 commit comments

Comments
 (0)