/**
* Reload an entry.
- * 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).
+ * 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).
*
* @ApiDoc(
* requirements={
$this->validateAuthentication();
$this->validateUserAccess($entry->getUser()->getId());
- // put default title in case of fetching content failed
- $entry->setTitle('No title found');
-
try {
$entry = $this->get('wallabag_core.content_proxy')->updateEntry($entry, $entry->getUrl());
} catch (\Exception $e) {
'entry' => $entry,
]);
- return new JsonResponse([], 304);
+ return new JsonResponse(['error' => 'Error while trying to fetch content'], 400);
}
// if refreshing entry failed, don't save it
if ($this->getParameter('wallabag_core.fetching_error_message') === $entry->getContent()) {
- return new JsonResponse([], 304);
+ return new JsonResponse(['error' => 'Error while trying to extract content'], 400);
}
$em = $this->getDoctrine()->getManager();
}
$this->client->request('PATCH', '/api/entries/'.$entry->getId().'/reload.json');
- $this->assertEquals(304, $this->client->getResponse()->getStatusCode());
+ $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'));
}
public function testReloadEntry()