Handle empty image proxy responses
This commit is contained in:
@@ -301,6 +301,13 @@ int image_proxy_handler(UrlParams *params) {
|
|||||||
int cache_ttl = get_cache_ttl_image();
|
int cache_ttl = get_cache_ttl_image();
|
||||||
|
|
||||||
if (cache_get(cache_key, cache_ttl, &cached_data, &cached_size) == 0) {
|
if (cache_get(cache_key, cache_ttl, &cached_data, &cached_size) == 0) {
|
||||||
|
if (!cached_data || cached_size == 0) {
|
||||||
|
free(cached_data);
|
||||||
|
free(cache_key);
|
||||||
|
send_response("Empty cached image response");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
char content_type[64] = {0};
|
char content_type[64] = {0};
|
||||||
|
|
||||||
const char *ext = strrchr(url, '.');
|
const char *ext = strrchr(url, '.');
|
||||||
@@ -406,6 +413,13 @@ int image_proxy_handler(UrlParams *params) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (buf.size == 0) {
|
||||||
|
free(buf.data);
|
||||||
|
free(cache_key);
|
||||||
|
send_response("Empty image response");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (strlen(content_type) == 0 ||
|
if (strlen(content_type) == 0 ||
|
||||||
strncmp(content_type, "image/", 6) != 0) {
|
strncmp(content_type, "image/", 6) != 0) {
|
||||||
free(buf.data);
|
free(buf.data);
|
||||||
|
|||||||
Reference in New Issue
Block a user