Merge pull request #2212 from dhensby/patch-3

Adding test to prove issue with HTTP Header parsing in RestfulService
This commit is contained in:
Ingo Schommer 2013-07-10 08:32:04 -07:00
commit ed69a2bf82
2 changed files with 3 additions and 1 deletions

View File

@ -352,7 +352,7 @@ class RestfulService extends ViewableData {
$match[1] = preg_replace_callback( $match[1] = preg_replace_callback(
'/(?<=^|[\x09\x20\x2D])./', '/(?<=^|[\x09\x20\x2D])./',
create_function('$matches', 'return strtoupper($matches[0]);'), create_function('$matches', 'return strtoupper($matches[0]);'),
strtolower(trim($match[1])) trim($match[1])
); );
if( isset($headers[$match[1]]) ) { if( isset($headers[$match[1]]) ) {
if (!is_array($headers[$match[1]])) { if (!is_array($headers[$match[1]])) {

View File

@ -172,12 +172,14 @@ class RestfulServiceTest extends SapphireTest {
public function testHttpHeaderParseing() { public function testHttpHeaderParseing() {
$headers = "content-type: text/html; charset=UTF-8\r\n". $headers = "content-type: text/html; charset=UTF-8\r\n".
"Server: Funky/1.0\r\n". "Server: Funky/1.0\r\n".
"X-BB-ExampleMANycaPS: test\r\n".
"Set-Cookie: foo=bar\r\n". "Set-Cookie: foo=bar\r\n".
"Set-Cookie: baz=quux\r\n". "Set-Cookie: baz=quux\r\n".
"Set-Cookie: bar=foo\r\n"; "Set-Cookie: bar=foo\r\n";
$expected = array( $expected = array(
'Content-Type' => 'text/html; charset=UTF-8', 'Content-Type' => 'text/html; charset=UTF-8',
'Server' => 'Funky/1.0', 'Server' => 'Funky/1.0',
'X-BB-ExampleMANycaPS' => 'test',
'Set-Cookie' => array( 'Set-Cookie' => array(
'foo=bar', 'foo=bar',
'baz=quux', 'baz=quux',