Skip to content

Commit

Permalink
Treat empty Accept header like any content type
Browse files Browse the repository at this point in the history
  • Loading branch information
jn-jairo committed Dec 26, 2017
1 parent 1f6b32e commit 3dc1dfe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Illuminate/Http/Concerns/InteractsWithContentTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ public function wantsAnyContentType()
{
$acceptable = $this->getAcceptableContentTypes();

if (count($acceptable) === 0) {
return true;
}

return isset($acceptable[0]) && ($acceptable[0] === '*/*' || $acceptable[0] === '*');
}

Expand Down
3 changes: 3 additions & 0 deletions tests/Http/HttpRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,9 @@ public function testExpectsJson()
$request = Request::create('/', 'GET', [], [], [], ['HTTP_ACCEPT' => '*/*', 'HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest']);
$this->assertTrue($request->expectsJson());

$request = Request::create('/', 'GET', [], [], [], ['HTTP_ACCEPT' => null, 'HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest']);
$this->assertTrue($request->expectsJson());

$request = Request::create('/', 'GET', [], [], [], ['HTTP_ACCEPT' => '*/*', 'HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest', 'HTTP_X_PJAX' => 'true']);
$this->assertFalse($request->expectsJson());

Expand Down

0 comments on commit 3dc1dfe

Please sign in to comment.