diff options
author | Andrei Belov <defan@nginx.com> | 2020-11-19 21:19:57 +0300 |
---|---|---|
committer | Andrei Belov <defan@nginx.com> | 2020-11-19 21:19:57 +0300 |
commit | 7f9079a3cd4cdb6ac3fea53f10bd34fe8b82fe9c (patch) | |
tree | c79dc48a3260156f3f824ecd299e5a4934d749c5 /src/java/nginx/unit/Response.java | |
parent | 646d047e5d12515ceac02279b373601ce0752982 (diff) | |
parent | 806a9b2515c60b12a68cd97af04f7fa5cb4dffed (diff) | |
download | unit-7f9079a3cd4cdb6ac3fea53f10bd34fe8b82fe9c.tar.gz unit-7f9079a3cd4cdb6ac3fea53f10bd34fe8b82fe9c.tar.bz2 |
Merged with the default branch.1.21.0-1
Diffstat (limited to '')
-rw-r--r-- | src/java/nginx/unit/Response.java | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/java/nginx/unit/Response.java b/src/java/nginx/unit/Response.java index 099d7f15..268b359d 100644 --- a/src/java/nginx/unit/Response.java +++ b/src/java/nginx/unit/Response.java @@ -40,11 +40,13 @@ public class Response implements HttpServletResponse { private String characterEncoding = defaultCharacterEncoding; private String contentType = null; private String contentTypeHeader = null; + private Locale locale = null; private static final Charset ISO_8859_1 = StandardCharsets.ISO_8859_1; private static final Charset UTF_8 = StandardCharsets.UTF_8; private static final String CONTENT_TYPE = "Content-Type"; + private static final byte[] CONTENT_LANGUAGE_BYTES = "Content-Language".getBytes(ISO_8859_1); private static final byte[] SET_COOKIE_BYTES = "Set-Cookie".getBytes(ISO_8859_1); private static final byte[] EXPIRES_BYTES = "Expires".getBytes(ISO_8859_1); @@ -590,9 +592,13 @@ public class Response implements HttpServletResponse { @Override public Locale getLocale() { - log("getLocale"); + trace("getLocale"); - return null; + if (locale == null) { + return Locale.getDefault(); + } + + return locale; } @Override @@ -795,7 +801,16 @@ public class Response implements HttpServletResponse { @Override public void setLocale(Locale loc) { - log("setLocale: " + loc); + trace("setLocale: " + loc); + + if (loc == null || isCommitted()) { + return; + } + + locale = loc; + String lang = locale.toString().replace('_', '-'); + + setHeader(req_info_ptr, CONTENT_LANGUAGE_BYTES, lang.getBytes(ISO_8859_1)); } private void log(String msg) |