aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJeremy Benoist <j0k3r@users.noreply.github.com>2016-11-22 11:27:55 +0100
committerGitHub <noreply@github.com>2016-11-22 11:27:55 +0100
commitbb28368f6953e07dbe6747d7c1eacf1abe35817e (patch)
treebac9d0e78d0908fa3c8e4c22900a6d7b2d456735
parent944b8d61752bedd126e1cdaeb3205177e414cf6b (diff)
parent5cd0857e3c87541fa8a628b0623b8959bfba2ca8 (diff)
downloadwallabag-bb28368f6953e07dbe6747d7c1eacf1abe35817e.tar.gz
wallabag-bb28368f6953e07dbe6747d7c1eacf1abe35817e.tar.zst
wallabag-bb28368f6953e07dbe6747d7c1eacf1abe35817e.zip
Merge pull request #2635 from wallabag/304-reload
Return 304 when content isn't reloaded using the API
-rw-r--r--src/Wallabag/ApiBundle/Controller/EntryRestController.php6
-rw-r--r--tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php6
2 files changed, 4 insertions, 8 deletions
diff --git a/src/Wallabag/ApiBundle/Controller/EntryRestController.php b/src/Wallabag/ApiBundle/Controller/EntryRestController.php
index 1a726b6e..2c2ec0c1 100644
--- a/src/Wallabag/ApiBundle/Controller/EntryRestController.php
+++ b/src/Wallabag/ApiBundle/Controller/EntryRestController.php
@@ -287,7 +287,7 @@ class EntryRestController extends WallabagRestController
287 287
288 /** 288 /**
289 * Reload an entry. 289 * Reload an entry.
290 * 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). 290 * 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).
291 * 291 *
292 * @ApiDoc( 292 * @ApiDoc(
293 * requirements={ 293 * requirements={
@@ -310,12 +310,12 @@ class EntryRestController extends WallabagRestController
310 'entry' => $entry, 310 'entry' => $entry,
311 ]); 311 ]);
312 312
313 return new JsonResponse(['error' => 'Error while trying to fetch content'], 400); 313 return new JsonResponse([], 304);
314 } 314 }
315 315
316 // if refreshing entry failed, don't save it 316 // if refreshing entry failed, don't save it
317 if ($this->getParameter('wallabag_core.fetching_error_message') === $entry->getContent()) { 317 if ($this->getParameter('wallabag_core.fetching_error_message') === $entry->getContent()) {
318 return new JsonResponse(['error' => 'Error while trying to extract content'], 400); 318 return new JsonResponse([], 304);
319 } 319 }
320 320
321 $em = $this->getDoctrine()->getManager(); 321 $em = $this->getDoctrine()->getManager();
diff --git a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
index 432ce7d8..409a8291 100644
--- a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
+++ b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
@@ -690,11 +690,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
690 } 690 }
691 691
692 $this->client->request('PATCH', '/api/entries/'.$entry->getId().'/reload.json'); 692 $this->client->request('PATCH', '/api/entries/'.$entry->getId().'/reload.json');
693 $this->assertEquals(400, $this->client->getResponse()->getStatusCode()); 693 $this->assertEquals(304, $this->client->getResponse()->getStatusCode());
694
695 $this->assertContains('Error while trying to extract content', $this->client->getResponse()->getContent());
696
697 $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type'));
698 } 694 }
699 695
700 public function testReloadEntry() 696 public function testReloadEntry()