VALUE rho_ruby_create_mutex() { VALUE val = rb_funcall(rb_cMutex, rb_intern("new"), 0 ); rho_ruby_holdValue(val); return val; }
static VALUE _CreateRequestHash(HttpContextRef context, RouteRef route) { RAWTRACE("Creating Req Hash"); VALUE hash = rho_ruby_createHash(); rho_ruby_holdValue(hash); const char* applicationName = route->_application; addStrToHash(hash, "application", applicationName, strlen(applicationName)); const char* modelName = route->_model; addStrToHash(hash, "model", modelName, strlen(modelName)); if (route->_action!=NULL) { const char* actionName = route->_action; addStrToHash(hash, "action", actionName, strlen(actionName)); } if (route->_id!=NULL) { const char* _id = route->_id; addStrToHash(hash, "id", _id, strlen(_id)); } const char* method = HTTPGetMethod(context->_request->_method); addStrToHash(hash, "request-method", method, strlen(method)); const char* uri = context->_request->_uri; addStrToHash(hash, "request-uri", uri, strlen(uri)); const char* query = context->_request->_query == NULL ? "" : context->_request->_query; addStrToHash(hash, "request-query", query, strlen(query)); VALUE hash_headers = rho_ruby_createHash(); rho_ruby_holdValue(hash_headers); struct parsed_header* h = &context->_request->_cheaders.cl; for (int i = 0; i < sizeof(struct headers)/sizeof(struct parsed_header); i++) { if (h->_name) { char* name = trim(strdup(h->_name)); if (h->_type == HDR_STRING) { addStrToHash(hash_headers,name,h->_v.v_vec.ptr,h->_v.v_vec.len); } else if (h->_type == HDR_INT) { addIntToHash(hash_headers, name, h->_v.v_big_int); } else if (h->_type == HDR_DATE) { addTimeToHash(hash_headers, name, h->_v.v_time); } free(name); } h++; } addHashToHash(hash,"headers",hash_headers); rho_ruby_releaseValue(hash_headers); int buflen = CFDataGetLength(context->_rcvdBytes); if (buflen > 0) { addStrToHash(hash, "request-body", (char*)CFDataGetBytePtr(context->_rcvdBytes), buflen); } rho_ruby_releaseValue(hash); return hash; }