1
0
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:
Michael Dowling 2013-05-26 07:53:16 -07:00
commit 89c6d12090
4 changed files with 16 additions and 2 deletions

1
.gitignore vendored
View File

@ -1,6 +1,7 @@
# Ingore common cruft
.DS_STORE
coverage
.idea
# Ignore binary files
guzzle.phar

View File

@ -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);
}

View File

@ -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'], ':')) {

View File

@ -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
*/