Add caching headers to avatar endpoint.
This commit is contained in:
parent
182c87b983
commit
eab79ff1ad
1 changed files with 12 additions and 10 deletions
|
@ -1,5 +1,4 @@
|
|||
import logging
|
||||
import os
|
||||
|
||||
from flask import (abort, redirect, request, url_for, make_response, Response,
|
||||
Blueprint, send_from_directory, jsonify)
|
||||
|
@ -19,6 +18,7 @@ from util.seo import render_snapshot
|
|||
from util.cache import no_cache
|
||||
from endpoints.common import common_login, render_page_template, route_show_if, param_required
|
||||
from endpoints.csrf import csrf_protect, generate_csrf_token
|
||||
from endpoints.registry import set_cache_headers
|
||||
from util.names import parse_repository_name
|
||||
from util.useremails import send_email_changed
|
||||
from auth import scopes
|
||||
|
@ -184,15 +184,17 @@ def status():
|
|||
|
||||
|
||||
@app.route("/avatar/<avatar_hash>")
|
||||
def render_avatar(avatar_hash):
|
||||
@set_cache_headers
|
||||
def render_avatar(avatar_hash, headers):
|
||||
try:
|
||||
size = int(request.args.get('size', 16))
|
||||
except ValueError:
|
||||
size = 16
|
||||
|
||||
generated = Avatar.generate(size, avatar_hash)
|
||||
headers = {'Content-Type': 'image/png'}
|
||||
return make_response(generated, 200, headers)
|
||||
resp = make_response(generated, 200, {'Content-Type': 'image/png'})
|
||||
resp.headers.extend(headers)
|
||||
return resp
|
||||
|
||||
|
||||
@web.route('/tos', methods=['GET'])
|
||||
|
|
Reference in a new issue