char * calipso_request_get_header_value(calipso_request_t *request, char *header) { char *key, *val = NULL; calipso_pool_t *pool = calipso_request_get_pool(request); int keylen = cpo_strlen(header); if (pool && keylen) { key = cpo_pool_strndup_lower(pool, header, keylen); val = hash_table_get_data(request->header, key); cpo_pool_free(pool, key); } return val; }
static int mod_http_translate(calipso_request_t *request) { char *pathname = NULL; char *uri = NULL; char *documentroot = NULL; calipso_client_t *client = calipso_request_get_client(request); calipso_server_t *server = calipso_client_get_server(client); calipso_reply_t *reply = calipso_request_get_reply(request); calipso_resource_t *resource = calipso_reply_get_resource(reply); calipso_pool_t *pool = calipso_request_get_pool(request); int http_status = calipso_reply_get_status(reply); if ( calipso_http_status_is_error(http_status)) { TRACE(" http error %d\n", http_status); return (0); } if( remove_dots_from_uri_path(request->uri) == -1 ) { calipso_reply_set_status(reply, HTTP_BAD_REQUEST); return 0; } if (!cpo_uri_sanity_check( request->uri )) { calipso_reply_set_status(reply, HTTP_BAD_REQUEST); return 0; } uri = calipso_request_get_uri(request); //if (*uri != '/') { // calipso_reply_set_status(reply, HTTP_BAD_REQUEST); // return (0); //} documentroot = calipso_server_get_documentroot(server); if (!documentroot) { calipso_reply_set_status(reply, HTTP_BAD_REQUEST); return (0); } pathname = cpo_pool_malloc(pool, MAXPATHLEN); strlcpy(pathname, documentroot, MAXPATHLEN); cpo_uri_strdecode(uri, uri); if (strlcat(pathname, uri, MAXPATHLEN) >= MAXPATHLEN) { calipso_reply_set_status(reply, HTTP_REQUEST_URI_TOO_LARGE); return (0); } /* security chek */ //if (!cpo_uri_sanity_check( pathname )) { // calipso_reply_set_status(reply, HTTP_BAD_REQUEST); // return 0; //} /* decode string */ //cpo_uri_strdecode(pathname, pathname); calipso_resource_set_path(resource, pathname); return 1; }