#endif
/* test default location if failed (templates == English translation base templates) */
- if (!text)
+ if (!text) {
text = errorTryLoadText(page_name, DEFAULT_SQUID_ERROR_DIR"/templates");
+ }
/* giving up if failed */
if (!text)
{
ErrorState *err = new ErrorState;
err->page_id = type; /* has to be reset manually if needed */
+ err->err_language = NULL;
err->type = type;
err->httpStatus = status;
safe_free(err->ftp.reply);
AUTHUSERREQUESTUNLOCK(err->auth_user_request, "errstate");
safe_free(err->err_msg);
+#if USE_ERR_LOCALES
+ if(err->err_language != Config.errorDefaultLanguage)
+#endif
+ safe_free(err->err_language);
cbdataFree(err);
}
*/
httpHeaderPutStrf(&rep->header, HDR_X_SQUID_ERROR, "%s %d", name, xerrno);
- /* add the Content-Language header according to RFC section 14.21 */
+#if USE_ERR_LOCALES
+ /*
+ * If error page auto-negotiate is enabled in any way, send the Vary.
+ * RFC 2616 section 13.6 and 14.44 says MAY and SHOULD do this.
+ * We have even better reasons though:
+ * see http://wiki.squid-cache.org/KnowledgeBase/VaryNotCaching
+ */
+ if(!Config.errorDirectory) {
+ /* We 'negotiated' this ONLY from the Accept-Language. */
+ httpHeaderDelById(&rep->header, HDR_VARY);
+ httpHeaderPutStrf(&rep->header, HDR_VARY, "Accept-Language");
+ }
+
+ /* add the Content-Language header according to RFC section 14.12 */
if(err_language) {
httpHeaderPutStrf(&rep->header, HDR_CONTENT_LANGUAGE, "%s", err_language);
- /* TODO: do we need to modify Vary: header as well? */
}
- else {
+ else
+#endif /* USE_ERROR_LOCALES */
+ {
/* default templates are in English */
- httpHeaderPutStrf(&rep->header, HDR_CONTENT_LANGUAGE, "en");
+ /* language is known unless error_directory override used */
+ if(!Config.errorDirectory)
+ httpHeaderPutStrf(&rep->header, HDR_CONTENT_LANGUAGE, "en");
}
httpBodySet(&rep->body, content);
*/
if(!m) {
m = error_text[page_id];
+#if USE_ERR_LOCALES
+ if(!Config.errorDirectory)
+ err_language = Config.errorDefaultLanguage;
+#endif
debugs(4, 1, HERE << "No existing languages found. Fall back on default language.");
}