Permalink
Browse files

Fixing parsing of content types with version number.

  • Loading branch information...
1 parent fdeaa8e commit 63487828d7b831ad1a16391af3f5900b84bebe7c @davidpersson davidpersson committed with nateabele Jun 11, 2012
Showing with 8 additions and 1 deletion.
  1. +1 −1 net/http/Response.php
  2. +7 −0 tests/cases/net/http/ResponseTest.php
View
2 net/http/Response.php
@@ -107,7 +107,7 @@ protected function _init() {
$this->body = $this->_httpChunkedDecode($this->body);
}
if (isset($this->headers['Content-Type'])) {
- $pattern = '/([-\w\/+]+)(;\s*?charset=(.+))?/i';
+ $pattern = '/([-\w\/\.+]+)(;\s*?charset=(.+))?/i';
preg_match($pattern, $this->headers['Content-Type'], $match);
if (isset($match[1])) {
View
7 tests/cases/net/http/ResponseTest.php
@@ -89,6 +89,13 @@ public function testParsingContentTypeWithoutEncoding() {
$this->assertEqual('UTF-8', $response->encoding); //default
}
+ public function testParsingContentTypeWithVersionNumber() {
+ $response = new Response(array('headers' => array(
+ 'Content-Type' => 'application/x-amz-json-1.0'
+ )));
+ $this->assertEqual('application/x-amz-json-1.0', $response->type);
+ }
+
public function testConstructionWithBody() {
$response = new Response(array('message' => "Content-type: image/jpeg\r\n\r\nimage data"));
$this->assertEqual("image data", $response->body());

0 comments on commit 6348782

Please sign in to comment.