From 89e7b06094d5168e7672caf925eb9f0bbe38ee29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C4=81rti=C5=86=C5=A1=20Tere=C5=A1ko?= Date: Mon, 7 Mar 2016 04:51:44 +0200 Subject: [PATCH 1/8] no point in mocking methods that do not exist --- .../unit/Fracture/Http/RequestBuilderTest.php | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/tests/unit/Fracture/Http/RequestBuilderTest.php b/tests/unit/Fracture/Http/RequestBuilderTest.php index a0ecb6a..4194ad5 100644 --- a/tests/unit/Fracture/Http/RequestBuilderTest.php +++ b/tests/unit/Fracture/Http/RequestBuilderTest.php @@ -175,7 +175,7 @@ public function testWhenContentParsersApplied() ], ]; - $builder = $this->getMock('Fracture\Http\RequestBuilder', ['applyContentParsers', 'isCLI']); + $builder = $this->getMock('Fracture\Http\RequestBuilder', ['applyContentParsers']); $builder->expects($this->once()) ->method('applyContentParsers') @@ -199,7 +199,7 @@ public function testWhenContentParsersIgnored() ], ]; - $builder = $this->getMock('Fracture\Http\RequestBuilder', ['applyContentParsers', 'isCLI']); + $builder = $this->getMock('Fracture\Http\RequestBuilder', ['applyContentParsers']); $builder->expects($this->never()) ->method('applyContentParsers'); @@ -228,8 +228,7 @@ public function testAppliedContentParsers() ], ]; - $builder = $this->getMock('Fracture\Http\RequestBuilder', ['isCLI']); - + $builder = new RequestBuilder; $builder->addContentParser('application/json', function () { return ['foo' => 'bar']; }); @@ -261,8 +260,7 @@ public function testAppliedContentParsersOverridesPameters() ], ]; - $builder = $this->getMock('Fracture\Http\RequestBuilder', ['isCLI']); - + $builder = new RequestBuilder; $builder->addContentParser('application/json', function () { return ['foo' => 'different']; }); @@ -296,8 +294,7 @@ public function testAppliedContentParsersWithBadReturn() ], ]; - $builder = $this->getMock('Fracture\Http\RequestBuilder', ['isCLI']); - + $builder = new RequestBuilder; $builder->addContentParser('application/json', function () { return null; }); @@ -324,8 +321,7 @@ public function testAppliedContentParsersWithMissingHeader() ], ]; - $builder = $this->getMock('Fracture\Http\RequestBuilder', ['isCLI']); - + $builder = new RequestBuilder; $builder->addContentParser('application/json', function () { return ['foo' => 'bar']; }); @@ -349,8 +345,7 @@ public function testAppliedContentParsersWithHeader() ], ]; - $builder = $this->getMock('Fracture\Http\RequestBuilder', ['isCLI']); - + $builder = new RequestBuilder; $builder->addContentParser('text/html', function ($header) { return ['foo' => $header->getParameter('version')]; }); From e5b9d318cfd5520188713b4e20c6d27743037b66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C4=81rti=C5=86=C5=A1=20Tere=C5=A1ko?= Date: Mon, 7 Mar 2016 04:59:15 +0200 Subject: [PATCH 2/8] passing Request instance to content parser --- src/Fracture/Http/RequestBuilder.php | 7 ++--- .../unit/Fracture/Http/RequestBuilderTest.php | 26 +++++++++++++++++++ 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/Fracture/Http/RequestBuilder.php b/src/Fracture/Http/RequestBuilder.php index cde324d..bea7c75 100644 --- a/src/Fracture/Http/RequestBuilder.php +++ b/src/Fracture/Http/RequestBuilder.php @@ -70,7 +70,7 @@ protected function applyContentParsers($instance) foreach ($this->parsers as $type => $parser) { if ($header->contains($type)) { - $parameters += $this->alterParameters($parser, $type, $header); + $parameters += $this->alterParameters($parser, $type, $header, $instance); } } @@ -81,10 +81,11 @@ protected function applyContentParsers($instance) * @param callable $parser * @param string $type * @param Headers\ContentType $header + * @param Request $instance */ - private function alterParameters($parser, $type, $header) + private function alterParameters($parser, $type, $header, $instance) { - $result = call_user_func($parser, $header); + $result = call_user_func($parser, $header, $instance); if (false === is_array($result)) { $message = "Parser for '$type' did not return a 'name => value' array of parameters"; diff --git a/tests/unit/Fracture/Http/RequestBuilderTest.php b/tests/unit/Fracture/Http/RequestBuilderTest.php index 4194ad5..837cecd 100644 --- a/tests/unit/Fracture/Http/RequestBuilderTest.php +++ b/tests/unit/Fracture/Http/RequestBuilderTest.php @@ -355,6 +355,32 @@ public function testAppliedContentParsersWithHeader() } + /** + * @covers Fracture\Http\RequestBuilder::create + * @covers Fracture\Http\RequestBuilder::applyContentParsers + * @covers Fracture\Http\RequestBuilder::addContentParser + */ + public function testAppliedContentParsersWithRequest() + { + $input = [ + 'get' => [ + 'test' => 'value', + ], + 'server' => [ + 'CONTENT_TYPE' => 'text/html', + ], + ]; + + $builder = new RequestBuilder; + $builder->addContentParser('text/html', function ($header, $request) { + return ['duplicate' => $request->getParameter('test')]; + }); + + $instance = $builder->create($input); + $this->assertEquals('value', $instance->getParameter('duplicate')); + } + + /** * @covers Fracture\Http\RequestBuilder::create * @covers Fracture\Http\RequestBuilder::applyContentParsers From 50ba8d254597f0ecabb16e18dd43995c7d3c9223 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C4=81rti=C5=86=C5=A1=20Tere=C5=A1ko?= Date: Mon, 7 Mar 2016 05:09:45 +0200 Subject: [PATCH 3/8] adding additional test to verify request override functionality --- .../unit/Fracture/Http/RequestBuilderTest.php | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/unit/Fracture/Http/RequestBuilderTest.php b/tests/unit/Fracture/Http/RequestBuilderTest.php index 837cecd..1c1141a 100644 --- a/tests/unit/Fracture/Http/RequestBuilderTest.php +++ b/tests/unit/Fracture/Http/RequestBuilderTest.php @@ -381,6 +381,34 @@ public function testAppliedContentParsersWithRequest() } + /** + * @covers Fracture\Http\RequestBuilder::create + * @covers Fracture\Http\RequestBuilder::applyContentParsers + * @covers Fracture\Http\RequestBuilder::addContentParser + */ + public function testOverrideRequestMethodWithParser() + { + $input = [ + 'get' => [ + '_mark' => 'put', + ], + 'server' => [ + 'CONTENT_TYPE' => 'text/html', + ], + ]; + + $builder = new RequestBuilder; + $builder->addContentParser('text/html', function ($header, $request) { + $method = $request->getParameter('_mark'); + $request->setMethod($method); + return []; + }); + + $instance = $builder->create($input); + $this->assertEquals('put', $instance->getMethod()); + } + + /** * @covers Fracture\Http\RequestBuilder::create * @covers Fracture\Http\RequestBuilder::applyContentParsers From 60cb960a3694cfee95275127ccf495a4dda30e64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C4=81rti=C5=86=C5=A1=20Tere=C5=A1ko?= Date: Mon, 7 Mar 2016 05:19:18 +0200 Subject: [PATCH 4/8] removing request method resolver and associated tests --- src/Fracture/Http/Request.php | 25 ++------------ tests/unit/Fracture/Http/RequestTest.php | 44 ------------------------ 2 files changed, 3 insertions(+), 66 deletions(-) diff --git a/src/Fracture/Http/Request.php b/src/Fracture/Http/Request.php index 66147da..33e1055 100644 --- a/src/Fracture/Http/Request.php +++ b/src/Fracture/Http/Request.php @@ -30,26 +30,6 @@ public function __construct($fileBagBuilder = null) } - private function getResolvedMethod() - { - $method = $this->method; - - // to mimic RESTlike API this lets you define override - // for request method in form element with name '_method' - if (array_key_exists('_method', $this->parameters)) { - $replacement = strtolower($this->parameters['_method']); - - if (in_array($replacement, ['post', 'put', 'delete'])) { - $method = $replacement; - } - - unset($this->parameters['_method']); - } - - return $method; - } - - private function getResolvedAcceptHeader() { $header = $this->acceptHeader; @@ -69,7 +49,6 @@ private function getResolvedAcceptHeader() public function prepare() { - $this->method = $this->getResolvedMethod(); $this->acceptHeader = $this->getResolvedAcceptHeader(); } @@ -101,7 +80,9 @@ public function getParameter($name) public function setMethod($value) { $method = strtolower($value); - $this->method = $method; + if (in_array($method, ['get', 'post', 'put', 'delete', 'head', 'options', 'trace'])) { + $this->method = $method; + } } diff --git a/tests/unit/Fracture/Http/RequestTest.php b/tests/unit/Fracture/Http/RequestTest.php index 39ea97e..6611091 100644 --- a/tests/unit/Fracture/Http/RequestTest.php +++ b/tests/unit/Fracture/Http/RequestTest.php @@ -28,8 +28,6 @@ public function testMethodGetterForUnpreparedRequest() * @covers Fracture\Http\Request::getMethod * @covers Fracture\Http\Request::prepare * - * @covers Fracture\Http\Request::getResolvedMethod - * * @depends testMethodGetterForUnpreparedRequest */ public function testMethodGetterForPreparedRequest() @@ -55,28 +53,6 @@ public function testMethodGetterForUnpreparedRequestWithCustomMethod() } - - - /** - * @covers Fracture\Http\Request::setParameters - * @covers Fracture\Http\Request::setMethod - * @covers Fracture\Http\Request::getMethod - * @covers Fracture\Http\Request::prepare - * - * @covers Fracture\Http\Request::getResolvedMethod - * - * @depends testMethodGetterForPreparedRequest - */ - public function testMethodGetterForPreparedRequestWithCustomMethodAndOverride() - { - $request = new Request; - $request->setParameters(['_method' => 'PUT']); - $request->prepare(); - - $this->assertEquals('put', $request->getMethod()); - } - - /** * @covers Fracture\Http\Request::getParameter */ @@ -111,26 +87,6 @@ public function testParameterGetterWithDifferentSetter() } - /** - * @covers Fracture\Http\Request::setParameters - * @covers Fracture\Http\Request::setMethod - * @covers Fracture\Http\Request::getMethod - * @covers Fracture\Http\Request::prepare - * @covers Fracture\Http\Request::getParameter - * - * @covers Fracture\Http\Request::getResolvedMethod - */ - public function testgetMethodForPreparedRequestUnsetsCustomMethod() - { - $request = new Request; - $request->setMethod('POST'); - $request->setParameters(['_method' => 'PUT']); - $request->prepare(); - - $this->assertNull($request->getParameter('_method')); - } - - /** * @covers Fracture\Http\Request::setParameters */ From d9de2a3d0860769e7b5ef51366b3930226157590 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C4=81rti=C5=86=C5=A1=20Tere=C5=A1ko?= Date: Mon, 7 Mar 2016 05:29:49 +0200 Subject: [PATCH 5/8] adding failing test and renaming method --- src/Fracture/Http/Headers/ContentType.php | 2 +- src/Fracture/Http/RequestBuilder.php | 2 +- .../Fracture/Http/Headers/ContentTypeTest.php | 18 +++++++-------- .../unit/Fracture/Http/RequestBuilderTest.php | 23 +++++++++++++++++++ 4 files changed, 34 insertions(+), 11 deletions(-) diff --git a/src/Fracture/Http/Headers/ContentType.php b/src/Fracture/Http/Headers/ContentType.php index 6333978..4b14e65 100644 --- a/src/Fracture/Http/Headers/ContentType.php +++ b/src/Fracture/Http/Headers/ContentType.php @@ -36,7 +36,7 @@ protected function extractData($headerValue) * @param string $type * @return bool */ - public function contains($type) + public function match($type) { return array_key_exists('value', $this->data) && $this->data['value'] === $type; } diff --git a/src/Fracture/Http/RequestBuilder.php b/src/Fracture/Http/RequestBuilder.php index bea7c75..d02d648 100644 --- a/src/Fracture/Http/RequestBuilder.php +++ b/src/Fracture/Http/RequestBuilder.php @@ -69,7 +69,7 @@ protected function applyContentParsers($instance) } foreach ($this->parsers as $type => $parser) { - if ($header->contains($type)) { + if ($header->match($type)) { $parameters += $this->alterParameters($parser, $type, $header, $instance); } } diff --git a/tests/unit/Fracture/Http/Headers/ContentTypeTest.php b/tests/unit/Fracture/Http/Headers/ContentTypeTest.php index c7085f1..b92a490 100644 --- a/tests/unit/Fracture/Http/Headers/ContentTypeTest.php +++ b/tests/unit/Fracture/Http/Headers/ContentTypeTest.php @@ -26,7 +26,7 @@ public function testEmptyInstance() /** * @covers Fracture\Http\Headers\ContentType::__construct * @covers Fracture\Http\Headers\ContentType::prepare - * @covers Fracture\Http\Headers\ContentType::contains + * @covers Fracture\Http\Headers\ContentType::match * * @covers Fracture\Http\Headers\ContentType::extractData */ @@ -35,15 +35,15 @@ public function testPreparedResult() $instance = new ContentType('text/html'); $instance->prepare(); - $this->assertTrue($instance->contains('text/html')); - $this->assertFalse($instance->contains('image/png')); + $this->assertTrue($instance->match('text/html')); + $this->assertFalse($instance->match('image/png')); } /** * @covers Fracture\Http\Headers\ContentType::__construct * @covers Fracture\Http\Headers\ContentType::prepare - * @covers Fracture\Http\Headers\ContentType::contains + * @covers Fracture\Http\Headers\ContentType::match * * @covers Fracture\Http\Headers\ContentType::extractData */ @@ -52,8 +52,8 @@ public function testPreparedCustomTypeResult() $instance = new ContentType('application/json;version=3'); $instance->prepare(); - $this->assertTrue($instance->contains('application/json')); - $this->assertFalse($instance->contains('application/json;version=3')); + $this->assertTrue($instance->match('application/json')); + $this->assertFalse($instance->match('application/json;version=3')); } @@ -61,7 +61,7 @@ public function testPreparedCustomTypeResult() * @covers Fracture\Http\Headers\ContentType::__construct * @covers Fracture\Http\Headers\ContentType::setValue * @covers Fracture\Http\Headers\ContentType::prepare - * @covers Fracture\Http\Headers\ContentType::contains + * @covers Fracture\Http\Headers\ContentType::match * * @covers Fracture\Http\Headers\ContentType::extractData */ @@ -71,8 +71,8 @@ public function testPreparedResultAterManualAlteration() $instance->setValue('image/png'); $instance->prepare(); - $this->assertTrue($instance->contains('image/png')); - $this->assertFalse($instance->contains('text/html')); + $this->assertTrue($instance->match('image/png')); + $this->assertFalse($instance->match('text/html')); } diff --git a/tests/unit/Fracture/Http/RequestBuilderTest.php b/tests/unit/Fracture/Http/RequestBuilderTest.php index 1c1141a..5d58198 100644 --- a/tests/unit/Fracture/Http/RequestBuilderTest.php +++ b/tests/unit/Fracture/Http/RequestBuilderTest.php @@ -409,6 +409,29 @@ public function testOverrideRequestMethodWithParser() } + /** + * @covers Fracture\Http\RequestBuilder::create + * @covers Fracture\Http\RequestBuilder::applyContentParsers + * @covers Fracture\Http\RequestBuilder::addContentParser + */ + public function testAppliedParserForWildecard() + { + $input = [ + 'server' => [ + 'CONTENT_TYPE' => 'text/html', + ], + ]; + + $builder = new RequestBuilder; + $builder->addContentParser('*/*', function ($header, $request) { + return ['called' => true]; + }); + + $instance = $builder->create($input); + $this->assertTrue($instance->getParameter('called')); + } + + /** * @covers Fracture\Http\RequestBuilder::create * @covers Fracture\Http\RequestBuilder::applyContentParsers From 13c5d3b36117ec7c5c30984527c3f4f82e50b28a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C4=81rti=C5=86=C5=A1=20Tere=C5=A1ko?= Date: Mon, 7 Mar 2016 05:36:29 +0200 Subject: [PATCH 6/8] changed my mind about naming --- src/Fracture/Http/Headers/ContentType.php | 10 +++++++++- .../Fracture/Http/Headers/ContentTypeTest.php | 18 +++++++++--------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/Fracture/Http/Headers/ContentType.php b/src/Fracture/Http/Headers/ContentType.php index 4b14e65..968f8ea 100644 --- a/src/Fracture/Http/Headers/ContentType.php +++ b/src/Fracture/Http/Headers/ContentType.php @@ -36,8 +36,16 @@ protected function extractData($headerValue) * @param string $type * @return bool */ - public function match($type) + public function contains($type) { return array_key_exists('value', $this->data) && $this->data['value'] === $type; } + + + public function match($type) + { + if ($this->contains($type)) { + return true; + } + } } diff --git a/tests/unit/Fracture/Http/Headers/ContentTypeTest.php b/tests/unit/Fracture/Http/Headers/ContentTypeTest.php index b92a490..c7085f1 100644 --- a/tests/unit/Fracture/Http/Headers/ContentTypeTest.php +++ b/tests/unit/Fracture/Http/Headers/ContentTypeTest.php @@ -26,7 +26,7 @@ public function testEmptyInstance() /** * @covers Fracture\Http\Headers\ContentType::__construct * @covers Fracture\Http\Headers\ContentType::prepare - * @covers Fracture\Http\Headers\ContentType::match + * @covers Fracture\Http\Headers\ContentType::contains * * @covers Fracture\Http\Headers\ContentType::extractData */ @@ -35,15 +35,15 @@ public function testPreparedResult() $instance = new ContentType('text/html'); $instance->prepare(); - $this->assertTrue($instance->match('text/html')); - $this->assertFalse($instance->match('image/png')); + $this->assertTrue($instance->contains('text/html')); + $this->assertFalse($instance->contains('image/png')); } /** * @covers Fracture\Http\Headers\ContentType::__construct * @covers Fracture\Http\Headers\ContentType::prepare - * @covers Fracture\Http\Headers\ContentType::match + * @covers Fracture\Http\Headers\ContentType::contains * * @covers Fracture\Http\Headers\ContentType::extractData */ @@ -52,8 +52,8 @@ public function testPreparedCustomTypeResult() $instance = new ContentType('application/json;version=3'); $instance->prepare(); - $this->assertTrue($instance->match('application/json')); - $this->assertFalse($instance->match('application/json;version=3')); + $this->assertTrue($instance->contains('application/json')); + $this->assertFalse($instance->contains('application/json;version=3')); } @@ -61,7 +61,7 @@ public function testPreparedCustomTypeResult() * @covers Fracture\Http\Headers\ContentType::__construct * @covers Fracture\Http\Headers\ContentType::setValue * @covers Fracture\Http\Headers\ContentType::prepare - * @covers Fracture\Http\Headers\ContentType::match + * @covers Fracture\Http\Headers\ContentType::contains * * @covers Fracture\Http\Headers\ContentType::extractData */ @@ -71,8 +71,8 @@ public function testPreparedResultAterManualAlteration() $instance->setValue('image/png'); $instance->prepare(); - $this->assertTrue($instance->match('image/png')); - $this->assertFalse($instance->match('text/html')); + $this->assertTrue($instance->contains('image/png')); + $this->assertFalse($instance->contains('text/html')); } From 888ad95f494d41d6f3629e50ec52394daebc5c0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C4=81rti=C5=86=C5=A1=20Tere=C5=A1ko?= Date: Mon, 7 Mar 2016 05:56:27 +0200 Subject: [PATCH 7/8] adding match() method for Content-Type header --- src/Fracture/Http/Headers/ContentType.php | 30 +++++++++++ .../Fracture/Http/Headers/ContentTypeTest.php | 51 +++++++++++++++++++ 2 files changed, 81 insertions(+) diff --git a/src/Fracture/Http/Headers/ContentType.php b/src/Fracture/Http/Headers/ContentType.php index 968f8ea..84f4076 100644 --- a/src/Fracture/Http/Headers/ContentType.php +++ b/src/Fracture/Http/Headers/ContentType.php @@ -47,5 +47,35 @@ public function match($type) if ($this->contains($type)) { return true; } + + return $this->isCompatible($this->data['value'], $type); + } + + + private function isCompatible($target, $pattern) + { + return $this->replaceStars($target, $pattern) === $this->replaceStars($pattern, $target); + } + + + /** + * @param string $target + * @param string $pattern + * @return string + */ + private function replaceStars($target, $pattern) + { + $target = explode('/', $target . '/*'); + $pattern = explode('/', $pattern . '/*'); + + if ($pattern[0] === '*') { + $target[0] = '*'; + } + + if ($pattern[1] === '*') { + $target[1] = '*'; + } + + return $target[0] . '/' . $target[1]; } } diff --git a/tests/unit/Fracture/Http/Headers/ContentTypeTest.php b/tests/unit/Fracture/Http/Headers/ContentTypeTest.php index c7085f1..ee24626 100644 --- a/tests/unit/Fracture/Http/Headers/ContentTypeTest.php +++ b/tests/unit/Fracture/Http/Headers/ContentTypeTest.php @@ -132,4 +132,55 @@ public function testGivenName() $instance = new ContentType; $this->assertSame('Content-Type', $instance->getName()); } + + + /** + * @covers Fracture\Http\Headers\ContentType::__construct + * @covers Fracture\Http\Headers\ContentType::prepare + * @covers Fracture\Http\Headers\ContentType::match + * + * @covers Fracture\Http\Headers\ContentType::isCompatible + * @covers Fracture\Http\Headers\ContentType::replaceStars + * + * @dataProvider provideMimeMatches + */ + public function testMimeMatches($expected, $value, $match) + { + $instance = new ContentType; + $instance->setValue($value); + $instance->prepare(); + $this->assertEquals($expected, $instance->match($match)); + } + + + public function provideMimeMatches() + { + return [ + [ + 'expected' => true, + 'value' => 'text/html', + 'match' => 'text/html', + ], + [ + 'expected' => false, + 'value' => 'text/html', + 'match' => 'text/plain', + ], + [ + 'expected' => true, + 'value' => 'text/html', + 'match' => 'text/*', + ], + [ + 'expected' => false, + 'value' => 'text/html', + 'match' => 'application/*', + ], + [ + 'expected' => true, + 'value' => 'application/json', + 'match' => '*/*', + ], + ]; + } } From 310635250763909cd9d4ee53970aee79f11866d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C4=81rti=C5=86=C5=A1=20Tere=C5=A1ko?= Date: Mon, 7 Mar 2016 06:16:08 +0200 Subject: [PATCH 8/8] docs: adding more if about content parsers --- README.md | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5c8f158..5f34c53 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ A simple abstraction for handling the HTTP request and responses. Library is mad You can add the library to your project using composer with following command: ```sh - composer require fracture/http +composer require fracture/http ``` @@ -67,8 +67,41 @@ $request = $builder->create([ ]); ``` -The parser itself is defined as an anonymous function, which will be called with `Fracture\Http\Headers\ContentType` as the parameter and is expected to return an array of `name => value` pairs for parameters. +Also the `RequestBuilder` instance can have multiple content parsers added. + +####Content parsers + +A parser is defined as an anonymous function, which will be called with `Fracture\Http\Headers\ContentType` and `Fracture\Http\Request` instances as parameters and is expected to return an array of `name => value` pairs for parameters. + +``` +array function([ Fracture\Http\Headers\ContentType $header [, Fracture\Http\Request $request]]) +``` + +You can also use content parsers to override `Request` attributes. For example, if you want to alter the request method, when submitting for with "magic" parameter like `` (which is a common approach for making more RESTful and bypass the limitations of standard webpage): ```php -array function([Fracture\Http\Headers\ContentType $header]) +addContentParser('*/*', function ($header, $request) { + $override = $request->getParameter('_my_method'); + if ($override) { + $request->setMethod($override); + } + return []; +}); ``` + + +###Accessing data in the request + +When the instance of `Request` has been fully initialized (using `RequestBuilder`), you gain ability to extract several types of information from this abstraction: + +####Parameters + + + +####Cookies +####File uploads +####Request method +####Headers