]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Return 304 when content isn't reloaded using the API 2635/head
authorJeremy Benoist <jeremy.benoist@gmail.com>
Tue, 22 Nov 2016 09:45:17 +0000 (10:45 +0100)
committerJeremy Benoist <jeremy.benoist@gmail.com>
Tue, 22 Nov 2016 09:45:19 +0000 (10:45 +0100)
Previously it was a 400 but this is more related to a real error.
Using the API user should only know the content got reloaded or not.
If reloaded: 200 otherwise: 304.

src/Wallabag/ApiBundle/Controller/EntryRestController.php
tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php

index 1a726b6edbcc776aa0ba2cb0f57ea862574732f1..2c2ec0c106ac1d72073649907f45a634ff7ad2ba 100644 (file)
@@ -287,7 +287,7 @@ class EntryRestController extends WallabagRestController
 
     /**
      * 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(
      *      requirements={
@@ -310,12 +310,12 @@ class EntryRestController extends WallabagRestController
                 '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 ($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();
index 432ce7d8907222611a7d3de6e9a9f9ae3189ea6a..409a82914680f8618139ced4632491fd61f34dc2 100644 (file)
@@ -690,11 +690,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
         }
 
         $this->client->request('PATCH', '/api/entries/'.$entry->getId().'/reload.json');
-        $this->assertEquals(400, $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'));
+        $this->assertEquals(304, $this->client->getResponse()->getStatusCode());
     }
 
     public function testReloadEntry()