mirror of
https://github.com/wallabag/wallabag.git
synced 2025-07-17 17:08:37 +00:00
Merge pull request #2635 from wallabag/304-reload
Return 304 when content isn't reloaded using the API
This commit is contained in:
commit
bb28368f69
2 changed files with 4 additions and 8 deletions
|
@ -287,7 +287,7 @@ class EntryRestController extends WallabagRestController
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reload an entry.
|
* Reload an entry.
|
||||||
* A response with HTTP Status 400 will be return if we weren't able to update the content (because it hasn't changed or we got an error).
|
* An empty response with HTTP Status 304 will be send if we weren't able to update the content (because it hasn't changed or we got an error).
|
||||||
*
|
*
|
||||||
* @ApiDoc(
|
* @ApiDoc(
|
||||||
* requirements={
|
* requirements={
|
||||||
|
@ -310,12 +310,12 @@ class EntryRestController extends WallabagRestController
|
||||||
'entry' => $entry,
|
'entry' => $entry,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return new JsonResponse(['error' => 'Error while trying to fetch content'], 400);
|
return new JsonResponse([], 304);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if refreshing entry failed, don't save it
|
// if refreshing entry failed, don't save it
|
||||||
if ($this->getParameter('wallabag_core.fetching_error_message') === $entry->getContent()) {
|
if ($this->getParameter('wallabag_core.fetching_error_message') === $entry->getContent()) {
|
||||||
return new JsonResponse(['error' => 'Error while trying to extract content'], 400);
|
return new JsonResponse([], 304);
|
||||||
}
|
}
|
||||||
|
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
|
@ -690,11 +690,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->client->request('PATCH', '/api/entries/'.$entry->getId().'/reload.json');
|
$this->client->request('PATCH', '/api/entries/'.$entry->getId().'/reload.json');
|
||||||
$this->assertEquals(400, $this->client->getResponse()->getStatusCode());
|
$this->assertEquals(304, $this->client->getResponse()->getStatusCode());
|
||||||
|
|
||||||
$this->assertContains('Error while trying to extract content', $this->client->getResponse()->getContent());
|
|
||||||
|
|
||||||
$this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testReloadEntry()
|
public function testReloadEntry()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue