mirror of
https://github.com/clearlinux/uwsgi.git
synced 2026-09-06 21:51:30 +00:00
completetd uwsgi.RequestBody jvm implementation
This commit is contained in:
@@ -94,3 +94,5 @@ int uwsgi_jvm_call_bool(jobject, jmethodID, ...);
|
||||
int uwsgi_jvm_consume_input_stream(struct wsgi_request *, size_t, jobject);
|
||||
jobject uwsgi_jvm_num(long);
|
||||
jobject uwsgi_jvm_request_body_input_stream(void);
|
||||
|
||||
size_t uwsgi_jvm_array_len(jobject);
|
||||
|
||||
@@ -67,8 +67,34 @@ JNIEXPORT jint JNICALL uwsgi_jvm_request_body_read(JNIEnv *env, jobject o) {
|
||||
return (jint) byte;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL uwsgi_jvm_request_body_read_bytearray(JNIEnv *env, jobject o, jobject b) {
|
||||
struct wsgi_request *wsgi_req = current_wsgi_req();
|
||||
ssize_t rlen = 0;
|
||||
size_t len = uwsgi_jvm_array_len(b);
|
||||
char *chunk = uwsgi_request_body_read(wsgi_req, len, &rlen);
|
||||
if (!chunk) {
|
||||
uwsgi_jvm_throw_io("error reading request body");
|
||||
return -1;
|
||||
}
|
||||
if (chunk == uwsgi.empty) {
|
||||
return -1;
|
||||
}
|
||||
char *buf = (char *) (*ujvm_env)->GetByteArrayElements(ujvm_env, b, JNI_FALSE);
|
||||
if (!buf) return -1;
|
||||
memcpy(buf, chunk, rlen);
|
||||
(*ujvm_env)->ReleaseByteArrayElements(ujvm_env, b, (jbyte *) buf, 0);
|
||||
return rlen;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL uwsgi_jvm_request_body_available(JNIEnv *env, jobject o) {
|
||||
struct wsgi_request *wsgi_req = current_wsgi_req();
|
||||
return (jint) (wsgi_req->post_cl - wsgi_req->post_pos);
|
||||
}
|
||||
|
||||
static JNINativeMethod uwsgi_jvm_request_body_methods[] = {
|
||||
{"read", "()I", (void *) &uwsgi_jvm_request_body_read},
|
||||
{"read", "([B)I", (void *) &uwsgi_jvm_request_body_read_bytearray},
|
||||
{"available", "()I", (void *) &uwsgi_jvm_request_body_available},
|
||||
};
|
||||
|
||||
static struct uwsgi_option uwsgi_jvm_options[] = {
|
||||
|
||||
Reference in New Issue
Block a user