implemented ring content-length

This commit is contained in:
Unbit
2013-03-06 12:25:09 +01:00
parent 89891c80ae
commit d96e394947
3 changed files with 34 additions and 0 deletions
+1
View File
@@ -87,3 +87,4 @@ void uwsgi_jvm_local_unref(jobject);
int uwsgi_jvm_call_bool(jobject, jmethodID, ...);
int uwsgi_jvm_consume_input_stream(struct wsgi_request *, size_t, jobject);
jobject uwsgi_jvm_num(long);
+12
View File
@@ -382,6 +382,18 @@ jobject uwsgi_jvm_iterator_next(jobject iterator) {
return uwsgi_jvm_call_object(iterator, mid);
}
jobject uwsgi_jvm_num(long num) {
static jmethodID mid = 0;
if (!mid) {
mid = uwsgi_jvm_get_method_id(ujvm.int_class, "<init>", "(I)V");
if (!mid) return NULL;
}
jobject o = (*ujvm_env)->NewObject(ujvm_env, ujvm.int_class, mid, num);
if (uwsgi_jvm_exception()) {
return NULL;
}
return o;
}
jobject uwsgi_jvm_str(char *str, size_t len) {
jobject new_str;
+21
View File
@@ -117,6 +117,23 @@ static int uwsgi_ring_request_item_add_keyword(jobject hm, char *key, size_t key
return ret;
}
static int uwsgi_ring_request_item_add_num(jobject hm, char *key, size_t keylen, long num) {
jobject j_key = uwsgi_ring_keyword(key, keylen);
if (!j_key) return -1;
jobject j_value = uwsgi_jvm_num(num);
if (!j_value) {
uwsgi_jvm_local_unref(j_key);
return -1;
}
int ret = uwsgi_jvm_hashmap_put(hm, j_key, j_value);
uwsgi_jvm_local_unref(j_key);
uwsgi_jvm_local_unref(j_value);
return ret;
}
// get the iterator from an Associative object
static jobject uwsgi_ring_Associative_iterator(jobject o) {
@@ -181,6 +198,10 @@ static int uwsgi_ring_request(struct wsgi_request *wsgi_req) {
if (uwsgi_ring_request_item_add(hm, "content-type", 12, wsgi_req->content_type, wsgi_req->content_type_len)) goto end;
}
if (wsgi_req->post_cl > 0) {
if (uwsgi_ring_request_item_add_num(hm, "content-length", 14, wsgi_req->post_cl)) goto end;
}
// convert the HashMap to Associative
request = uwsgi_ring_invoke2(uring.into, empty_request, hm);
if (!request) goto end;