diff options
| author | Andrew Clayton <a.clayton@nginx.com> | 2025-07-04 16:38:25 +0100 |
|---|---|---|
| committer | Andrew Clayton <a.clayton@nginx.com> | 2025-07-25 04:49:45 +0100 |
| commit | c8b859e373089d3f347efb806c9926823de41bf6 (patch) | |
| tree | 96f080acede9233e2b13e657ac371f1867fd8a90 /src/java/nxt_jni_Request.c | |
| parent | a9071e11602ec73b96302c852709c16c9d55996d (diff) | |
| download | unit-c8b859e373089d3f347efb806c9926823de41bf6.tar.gz unit-c8b859e373089d3f347efb806c9926823de41bf6.tar.bz2 | |
Set SERVER_PORT appropriately
The Perl, PHP, Python, Ruby & Java language modules all hard code
SERVER_PORT to "80".
Adjust them to bring them in line with the wasm language module which
uses r->local_port (I.e. the port unit accepted the connection on).
Closes: https://github.com/nginx/unit/issues/761
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
Diffstat (limited to 'src/java/nxt_jni_Request.c')
| -rw-r--r-- | src/java/nxt_jni_Request.c | 28 |
1 files changed, 3 insertions, 25 deletions
diff --git a/src/java/nxt_jni_Request.c b/src/java/nxt_jni_Request.c index 980a26b6..bc0d56dc 100644 --- a/src/java/nxt_jni_Request.c +++ b/src/java/nxt_jni_Request.c @@ -624,36 +624,14 @@ 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) { - jint res; - char *host, *colon, tmp; - nxt_unit_field_t *f; + char *p; nxt_unit_request_t *r; r = nxt_jlong2ptr(req_ptr); - f = nxt_java_findHeader(r->fields, r->fields + r->fields_count, - "Host", 4); - if (f != NULL) { - host = nxt_unit_sptr_get(&f->value); - - colon = memchr(host, ':', f->value_length); - - if (colon == NULL) { - return 80; - } - - tmp = host[f->value_length]; - - host[f->value_length] = '\0'; - - res = strtol(colon + 1, NULL, 10); - - host[f->value_length] = tmp; - - return res; - } + p = nxt_unit_sptr_get(&r->local_port); - return nxt_java_Request_getLocalPort(env, cls, req_ptr); + return strtol(p, NULL, 10); } |
