From 22de5fcddfacd8d241ae2926125e0151b9e6e651 Mon Sep 17 00:00:00 2001 From: Andrey Zelenkov Date: Mon, 11 Mar 2019 17:31:59 +0300 Subject: Style. --- src/java/nginx/unit/Context.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/java') diff --git a/src/java/nginx/unit/Context.java b/src/java/nginx/unit/Context.java index 643a336b..f6d5e339 100644 --- a/src/java/nginx/unit/Context.java +++ b/src/java/nginx/unit/Context.java @@ -306,7 +306,7 @@ public class Context implements ServletContext, InitParams PrintWriter writer = response.getWriter(); for (String n : ls) { - writer.println("" + n + "
"); + writer.println("" + n + "
"); } writer.close(); @@ -547,7 +547,7 @@ public class Context implements ServletContext, InitParams j = j.getParent(); } } - system_loader = j; + system_loader = j; } private boolean isSystemPath(String path) @@ -1733,7 +1733,7 @@ public class Context implements ServletContext, InitParams @Override public FileVisitResult visitFile( - Path file, BasicFileAttributes attrs) + Path file, BasicFileAttributes attrs) throws IOException { Files.delete(file); return FileVisitResult.CONTINUE; -- cgit From 452ce0789e8e8f1ac98cc0ed7efce03656a3d616 Mon Sep 17 00:00:00 2001 From: Max Romanov Date: Thu, 21 Mar 2019 13:55:57 +0300 Subject: Adjusting request schema value according to connection tls state. This closes #223 issue on GitHub. --- src/java/nginx/unit/Request.java | 6 ++++-- src/java/nxt_jni_Request.c | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) (limited to 'src/java') diff --git a/src/java/nginx/unit/Request.java b/src/java/nginx/unit/Request.java index dc73c656..b46d3f59 100644 --- a/src/java/nginx/unit/Request.java +++ b/src/java/nginx/unit/Request.java @@ -980,11 +980,13 @@ public class Request implements HttpServletRequest, DynamicPathRequest @Override public boolean isSecure() { - log("isSecure"); + trace("isSecure"); - return false; + return isSecure(req_ptr); } + private static native boolean isSecure(long req_ptr); + @Override public void removeAttribute(String name) { diff --git a/src/java/nxt_jni_Request.c b/src/java/nxt_jni_Request.c index 6fb9cb44..a9fbe0e4 100644 --- a/src/java/nxt_jni_Request.c +++ b/src/java/nxt_jni_Request.c @@ -56,6 +56,8 @@ static jstring JNICALL nxt_java_Request_getServerName(JNIEnv *env, jclass cls, jlong req_ptr); static jint JNICALL nxt_java_Request_getServerPort(JNIEnv *env, jclass cls, jlong req_ptr); +static jboolean JNICALL nxt_java_Request_isSecure(JNIEnv *env, jclass cls, + jlong req_ptr); static void JNICALL nxt_java_Request_log(JNIEnv *env, jclass cls, jlong req_info_ptr, jstring msg, jint msg_len); static void JNICALL nxt_java_Request_trace(JNIEnv *env, jclass cls, @@ -166,6 +168,10 @@ nxt_java_initRequest(JNIEnv *env, jobject cl) (char *) "(J)I", nxt_java_Request_getServerPort }, + { (char *) "isSecure", + (char *) "(J)Z", + nxt_java_Request_isSecure }, + { (char *) "log", (char *) "(JLjava/lang/String;I)V", nxt_java_Request_log }, @@ -603,6 +609,17 @@ nxt_java_Request_getServerPort(JNIEnv *env, jclass cls, jlong req_ptr) } +static jboolean JNICALL +nxt_java_Request_isSecure(JNIEnv *env, jclass cls, jlong req_ptr) +{ + nxt_unit_request_t *r; + + r = nxt_jlong2ptr(req_ptr); + + return r->tls != 0; +} + + static void JNICALL nxt_java_Request_log(JNIEnv *env, jclass cls, jlong req_info_ptr, jstring msg, jint msg_len) -- cgit From 6a2928b4bf3c57685b707c17eb0c147d68be1dd6 Mon Sep 17 00:00:00 2001 From: Max Romanov Date: Thu, 30 May 2019 15:02:07 +0300 Subject: Java: fixing request scheme using 'tls' flag. --- src/java/nginx/unit/Request.java | 2 +- src/java/nxt_jni_Request.c | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'src/java') diff --git a/src/java/nginx/unit/Request.java b/src/java/nginx/unit/Request.java index b46d3f59..3ba46f6c 100644 --- a/src/java/nginx/unit/Request.java +++ b/src/java/nginx/unit/Request.java @@ -920,7 +920,7 @@ public class Request implements HttpServletRequest, DynamicPathRequest @Override public String getScheme() { - log("getScheme"); + trace("getScheme"); return getScheme(req_ptr); } diff --git a/src/java/nxt_jni_Request.c b/src/java/nxt_jni_Request.c index a9fbe0e4..733290dd 100644 --- a/src/java/nxt_jni_Request.c +++ b/src/java/nxt_jni_Request.c @@ -542,7 +542,11 @@ nxt_java_Request_getRemotePort(JNIEnv *env, jclass cls, jlong req_ptr) static jstring JNICALL nxt_java_Request_getScheme(JNIEnv *env, jclass cls, jlong req_ptr) { - return (*env)->NewStringUTF(env, "http"); + nxt_unit_request_t *r; + + r = nxt_jlong2ptr(req_ptr); + + return (*env)->NewStringUTF(env, r->tls ? "https" : "http"); } -- cgit From 82415397346b7d8953b094f6dce867c1afdde420 Mon Sep 17 00:00:00 2001 From: Max Romanov Date: Thu, 30 May 2019 15:02:09 +0300 Subject: Java: fixing typo in context initialization. --- src/java/nxt_jni_Context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/java') diff --git a/src/java/nxt_jni_Context.c b/src/java/nxt_jni_Context.c index 8f7adddf..589e1c5b 100644 --- a/src/java/nxt_jni_Context.c +++ b/src/java/nxt_jni_Context.c @@ -55,7 +55,7 @@ nxt_java_initContext(JNIEnv *env, jobject cl) } nxt_java_Context_stop = (*env)->GetMethodID(env, cls, "stop", "()V"); - if (nxt_java_Context_service == NULL) { + if (nxt_java_Context_stop == NULL) { nxt_unit_warn(NULL, "nginx.unit.Context.stop() not found"); goto failed; } -- cgit