mirror of
https://github.com/guzzle/guzzle.git
synced 2025-02-25 02:22:57 +01:00
Merge pull request #329 from lstrojny/bug/incomplete-url
Allow incomplete URLs to be parsed correctly
This commit is contained in:
commit
89c6d12090
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,6 +1,7 @@
|
||||
# Ingore common cruft
|
||||
.DS_STORE
|
||||
coverage
|
||||
.idea
|
||||
|
||||
# Ignore binary files
|
||||
guzzle.phar
|
||||
|
@ -78,7 +78,7 @@ class RequestFactory implements RequestFactoryInterface
|
||||
$protocol = 'HTTP',
|
||||
$protocolVersion = '1.1'
|
||||
) {
|
||||
return $this->create($method, Url::buildUrl($urlParts, true), $headers, $body)
|
||||
return $this->create($method, Url::buildUrl($urlParts), $headers, $body)
|
||||
->setProtocolVersion($protocolVersion);
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ abstract class AbstractMessageParser implements MessageParserInterface
|
||||
} elseif (isset($parts['headers']['host'])) {
|
||||
$urlParts['host'] = $parts['headers']['host'];
|
||||
} else {
|
||||
$urlParts['host'] = '';
|
||||
$urlParts['host'] = null;
|
||||
}
|
||||
|
||||
if (false === strpos($urlParts['host'], ':')) {
|
||||
|
@ -310,6 +310,19 @@ class HttpRequestFactoryTest extends \Guzzle\Tests\GuzzleTestCase
|
||||
$this->assertEquals(0, (string) $request->getHeader('Content-Length'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Guzzle\Http\Message\RequestFactory::fromMessage
|
||||
* @covers Guzzle\Http\Message\RequestFactory::create
|
||||
*/
|
||||
public function testBugPathIncorrectlyHandled()
|
||||
{
|
||||
$message = "POST /foo\r\n\r\nBODY";
|
||||
$request = RequestFactory::getInstance()->fromMessage($message);
|
||||
$this->assertSame('POST', $request->getMethod());
|
||||
$this->assertSame('/foo', $request->getPath());
|
||||
$this->assertSame('BODY', (string) $request->getBody());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Guzzle\Http\Message\RequestFactory::create
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user