Endless HEAD request ?
Closed this issue · 2 comments
aaa2000 commented
| Q | A |
|---|---|
| Bug? | yes |
| New Feature? | no |
| Version | v1.0.0 |
Actual Behavior
A HEAD request is endless.
Expected Behavior
I expect that the HEAD request to end and to get a response
Steps to Reproduce
Reproducible with this melody script https://github.com/sensiolabs/melody
The guzzle http client has the expected behavior, using the http adapter, the head request doesn't end.
<?php
<<<CONFIG
packages:
- "php-http/guzzle5-adapter"
- "guzzlehttp/psr7"
- "php-http/message"
CONFIG;
use GuzzleHttp\Client as GuzzleClient;
use Http\Adapter\Guzzle5\Client as GuzzleAdapter;
use Http\Message\MessageFactory\GuzzleMessageFactory;
use Http\Message\Formatter\SimpleFormatter;
$guzzle = new GuzzleClient([]);
$request = $guzzle->createRequest('HEAD', 'http://example.com');
echo "send...\n\n";
$response = $guzzle->send($request);
echo "\n\nend guzzle...\n\n";
$messageFactory = new GuzzleMessageFactory();
$adapter = new GuzzleAdapter($guzzle, $messageFactory);
$request = $messageFactory->createRequest('HEAD', 'http://example.com');
echo "send...\n\n";
$response = $adapter->sendRequest($request);
echo (new SimpleFormatter())->formatRequest($request);
echo "\n\nend\n\n";
Possible Solutions
Maybe, it could be resolved by modifing the src/Client.php:76:
$options['body'] = '' === (string) $request->getBody() ? null : (string) $request->getBody()
Nyholm commented
When I run the script above I get:
[tobias@Tobias-MBP:~/Workspace/PHPStorm/httplug/tmp]
% melody run index.php 1 ↵
send...
end guzzle...
send...
HEAD http://example.com 1.1
end
[tobias@Tobias-MBP:~/Workspace/PHPStorm/httplug/tmp]
%
Nyholm commented
Ah, I get this error now.
I think this is an issue with Guzzle. But I do not mind allowing a workaround here.
Thank you!