Merge pull request #19723 from nextcloud/bug/18603/avatar-response
Always use status 200 for avatar response
This commit is contained in:
commit
6ea1aef031
2 changed files with 7 additions and 3 deletions
|
@ -144,8 +144,8 @@ class AvatarController extends Controller {
|
||||||
$avatarFile = $avatar->getFile($size);
|
$avatarFile = $avatar->getFile($size);
|
||||||
$response = new FileDisplayResponse(
|
$response = new FileDisplayResponse(
|
||||||
$avatarFile,
|
$avatarFile,
|
||||||
$avatar->isCustomAvatar() ? Http::STATUS_OK : Http::STATUS_CREATED,
|
Http::STATUS_OK,
|
||||||
['Content-Type' => $avatarFile->getMimeType()]
|
['Content-Type' => $avatarFile->getMimeType(), 'X-NC-IsCustomAvatar' => (int)$avatar->isCustomAvatar()]
|
||||||
);
|
);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return new JSONResponse([], Http::STATUS_NOT_FOUND);
|
return new JSONResponse([], Http::STATUS_NOT_FOUND);
|
||||||
|
|
|
@ -193,6 +193,8 @@ class AvatarControllerTest extends \Test\TestCase {
|
||||||
$this->assertEquals(Http::STATUS_OK, $response->getStatus());
|
$this->assertEquals(Http::STATUS_OK, $response->getStatus());
|
||||||
$this->assertArrayHasKey('Content-Type', $response->getHeaders());
|
$this->assertArrayHasKey('Content-Type', $response->getHeaders());
|
||||||
$this->assertEquals('image type', $response->getHeaders()['Content-Type']);
|
$this->assertEquals('image type', $response->getHeaders()['Content-Type']);
|
||||||
|
$this->assertArrayHasKey('X-NC-IsCustomAvatar', $response->getHeaders());
|
||||||
|
$this->assertEquals('1', $response->getHeaders()['X-NC-IsCustomAvatar']);
|
||||||
|
|
||||||
$this->assertEquals('my etag', $response->getETag());
|
$this->assertEquals('my etag', $response->getETag());
|
||||||
}
|
}
|
||||||
|
@ -206,9 +208,11 @@ class AvatarControllerTest extends \Test\TestCase {
|
||||||
|
|
||||||
$response = $this->avatarController->getAvatar('userId', 32);
|
$response = $this->avatarController->getAvatar('userId', 32);
|
||||||
|
|
||||||
$this->assertEquals(Http::STATUS_CREATED, $response->getStatus());
|
$this->assertEquals(Http::STATUS_OK, $response->getStatus());
|
||||||
$this->assertArrayHasKey('Content-Type', $response->getHeaders());
|
$this->assertArrayHasKey('Content-Type', $response->getHeaders());
|
||||||
$this->assertEquals('image type', $response->getHeaders()['Content-Type']);
|
$this->assertEquals('image type', $response->getHeaders()['Content-Type']);
|
||||||
|
$this->assertArrayHasKey('X-NC-IsCustomAvatar', $response->getHeaders());
|
||||||
|
$this->assertEquals('0', $response->getHeaders()['X-NC-IsCustomAvatar']);
|
||||||
|
|
||||||
$this->assertEquals('my etag', $response->getETag());
|
$this->assertEquals('my etag', $response->getETag());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue