mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-11-21 14:01:53 +03:00
Ensure error reporting in resource, about and file scheme fetchers is translated
This commit is contained in:
parent
c72b5671d7
commit
8249898501
@ -40,6 +40,7 @@
|
||||
#include "utils/corestrings.h"
|
||||
#include "utils/utils.h"
|
||||
#include "utils/ring.h"
|
||||
#include "utils/messages.h"
|
||||
|
||||
#include "content/fetch.h"
|
||||
#include "content/fetchers.h"
|
||||
@ -242,7 +243,9 @@ bool fetch_about_srverror(struct fetch_about_context *ctx)
|
||||
if (fetch_about_send_header(ctx, "Content-Type: text/plain"))
|
||||
return false;
|
||||
|
||||
res = fetch_about_ssenddataf(ctx, "Server error 500");
|
||||
res = fetch_about_ssenddataf(ctx, "%s 500 %s",
|
||||
messages_get("FetchErrorCode"),
|
||||
messages_get("HTTP500"));
|
||||
if (res != NSERROR_OK) {
|
||||
return false;
|
||||
}
|
||||
@ -498,7 +501,7 @@ static bool fetch_about_about_handler(struct fetch_about_context *ctx)
|
||||
fetch_set_http_code(ctx->fetchh, 200);
|
||||
|
||||
/* content type */
|
||||
if (fetch_about_send_header(ctx, "Content-Type: text/html"))
|
||||
if (fetch_about_send_header(ctx, "Content-Type: text/html; charset=utf-8"))
|
||||
goto fetch_about_config_handler_aborted;
|
||||
|
||||
res = fetch_about_ssenddataf(ctx,
|
||||
@ -546,16 +549,30 @@ static bool
|
||||
fetch_about_404_handler(struct fetch_about_context *ctx)
|
||||
{
|
||||
nserror res;
|
||||
const char *title;
|
||||
|
||||
/* content is going to return 404 */
|
||||
fetch_set_http_code(ctx->fetchh, 404);
|
||||
|
||||
/* content type */
|
||||
if (fetch_about_send_header(ctx, "Content-Type: text/plain; charset=utf-8")) {
|
||||
if (fetch_about_send_header(ctx,
|
||||
"Content-Type: text/html; charset=utf-8")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
res = fetch_about_ssenddataf(ctx, "Unknown page: %s", nsurl_access(ctx->url));
|
||||
title = messages_get("HTTP404");
|
||||
res = fetch_about_ssenddataf(ctx,
|
||||
"<html>\n<head>\n"
|
||||
"<title>%s</title>\n"
|
||||
"<link rel=\"stylesheet\" type=\"text/css\" "
|
||||
"href=\"resource:internal.css\">\n"
|
||||
"</head>\n"
|
||||
"<body class=\"ns-even-bg ns-even-fg ns-border\" id =\"fetcherror\">\n"
|
||||
"<h1 class=\"ns-border ns-odd-fg-bad\">%s</h1>\n"
|
||||
"<p>%s %d %s %s</p>\n"
|
||||
"</body>\n</html>\n",
|
||||
title, title, messages_get("FetchErrorCode"), 404,
|
||||
messages_get("FetchFile"),nsurl_access(ctx->url));
|
||||
if (res != NSERROR_OK) {
|
||||
return false;
|
||||
}
|
||||
|
@ -243,16 +243,26 @@ static void fetch_file_process_error(struct fetch_file_context *ctx, int code)
|
||||
fetch_set_http_code(ctx->fetchh, code);
|
||||
|
||||
/* content type */
|
||||
if (fetch_file_send_header(ctx, "Content-Type: text/html"))
|
||||
if (fetch_file_send_header(ctx, "Content-Type: text/html; charset=utf-8"))
|
||||
goto fetch_file_process_error_aborted;
|
||||
|
||||
snprintf(key, sizeof key, "HTTP%03d", code);
|
||||
title = messages_get(key);
|
||||
|
||||
snprintf(buffer, sizeof buffer, "<html><head><title>%s</title></head>"
|
||||
"<body><h1>%s</h1>"
|
||||
"<p>Error %d while fetching file %s</p></body></html>",
|
||||
title, title, code, nsurl_access(ctx->url));
|
||||
snprintf(buffer, sizeof buffer,
|
||||
"<html><head>"
|
||||
"<title>%s</title>"
|
||||
"<link rel=\"stylesheet\" type=\"text/css\" "
|
||||
"href=\"resource:internal.css\">\n"
|
||||
"</head>"
|
||||
"<body class=\"ns-even-bg ns-even-fg ns-border\" "
|
||||
"id =\"fetcherror\">\n"
|
||||
"<h1 class=\"ns-border ns-odd-fg-bad\">%s</h1>\n"
|
||||
"<p>%s %d %s %s</p>\n"
|
||||
"</body>\n</html>\n",
|
||||
title, title,
|
||||
messages_get("FetchErrorCode"), code,
|
||||
messages_get("FetchFile"), nsurl_access(ctx->url));
|
||||
|
||||
msg.type = FETCH_DATA;
|
||||
msg.data.header_or_data.buf = (const uint8_t *) buffer;
|
||||
@ -681,7 +691,7 @@ static void fetch_file_process_dir(struct fetch_file_context *ctx,
|
||||
goto fetch_file_process_dir_aborted;
|
||||
|
||||
/* content type */
|
||||
if (fetch_file_send_header(ctx, "Content-Type: text/html"))
|
||||
if (fetch_file_send_header(ctx, "Content-Type: text/html; charset=utf-8"))
|
||||
goto fetch_file_process_dir_aborted;
|
||||
|
||||
msg.type = FETCH_DATA;
|
||||
|
@ -229,16 +229,26 @@ static bool fetch_resource_notfound_handler(struct fetch_resource_context *ctx)
|
||||
fetch_set_http_code(ctx->fetchh, code);
|
||||
|
||||
/* content type */
|
||||
if (fetch_resource_send_header(ctx, "Content-Type: text/html"))
|
||||
if (fetch_resource_send_header(ctx, "Content-Type: text/html; charset=utf-8"))
|
||||
goto fetch_resource_notfound_handler_aborted;
|
||||
|
||||
snprintf(key, sizeof key, "HTTP%03d", code);
|
||||
title = messages_get(key);
|
||||
|
||||
snprintf(buffer, sizeof buffer, "<html><head><title>%s</title></head>"
|
||||
"<body><h1>%s</h1>"
|
||||
"<p>Error %d while fetching file %s</p></body></html>",
|
||||
title, title, code, nsurl_access(ctx->url));
|
||||
snprintf(buffer, sizeof buffer,
|
||||
"<html><head>"
|
||||
"<title>%s</title>"
|
||||
"<link rel=\"stylesheet\" type=\"text/css\" "
|
||||
"href=\"resource:internal.css\">\n"
|
||||
"</head>"
|
||||
"<body class=\"ns-even-bg ns-even-fg ns-border\" "
|
||||
"id =\"fetcherror\">\n"
|
||||
"<h1 class=\"ns-border ns-odd-fg-bad\">%s</h1>\n"
|
||||
"<p>%s %d %s %s</p>\n"
|
||||
"</body>\n</html>\n",
|
||||
title, title,
|
||||
messages_get("FetchErrorCode"), code,
|
||||
messages_get("FetchFile"), nsurl_access(ctx->url));
|
||||
|
||||
msg.type = FETCH_DATA;
|
||||
msg.data.header_or_data.buf = (const uint8_t *) buffer;
|
||||
|
@ -1560,17 +1560,26 @@ zh_CN.all.TryAgain:重试
|
||||
# =======================
|
||||
#
|
||||
en.all.FetchErrorTitle:Error occurred fetching page
|
||||
fr.all.FetchErrorTitle:Problème rencontré lors de la récupération de la page
|
||||
it.all.FetchErrorTitle:Errore durante il recupero della pagina
|
||||
zh_CN.all.FetchErrorTitle:获取页面时发生错误
|
||||
|
||||
en.all.FetchErrorDescription:An error occurred when connecting to %s
|
||||
fr.all.FetchErrorDescription:Une erreur s'est produite lors de la connexion à %s
|
||||
it.all.FetchErrorDescription:Si è verificato un errore durante la connessione a %s
|
||||
zh_CN.all.FetchErrorDescription:连接到 %s 时发生错误
|
||||
|
||||
# Generic fetcher failure (really a programming error)
|
||||
en.all.FetchFailedToFinish:The fetcher for this request failed to complete
|
||||
en.all.FetchFailedToFinish:The fetch for this request failed to complete
|
||||
fr.all.FetchFailedToFinish:La recherche de cette requête n’a pas réussi
|
||||
zh_CN.all.FetchFailedToFinish:无法完成此请求的提取程序
|
||||
|
||||
en.all.FetchErrorCode:Error code
|
||||
fr.all.FetchErrorCode:Code d'erreur
|
||||
|
||||
en.all.FetchFile:fetching file
|
||||
fr.all.FetchFile:récupérer le fichier
|
||||
|
||||
|
||||
# SSL certificate viewer
|
||||
# ======================
|
||||
|
Loading…
Reference in New Issue
Block a user