yeomann / mongoose

Automatically exported from code.google.com/p/mongoose
MIT License
0 stars 0 forks source link

Why does not support virtual directory in version 3.4 #391

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I need use the virtual directory , but it don't support on version 3.4.
I compared the code, It have get_document_root() function that is parsed the 
virtual directory in 3.0, but 3.4 havn't.

// Mongoose allows to specify multiple directories to serve,
// like /var/www,/~bob=/home/bob. That means that root directory depends on URI.
// This function returns root dir for given URI.
static int get_document_root(const struct mg_connection *conn,
struct vec *document_root) {
const char *root, *uri;
int len_of_matched_uri;
struct vec uri_vec, path_vec;

uri = conn->request_info.uri;
len_of_matched_uri = 0;
root = next_option(conn->ctx->config[DOCUMENT_ROOT], document_root, NULL);

while ((root = next_option(root, &uri_vec, &path_vec)) != NULL) {
if (memcmp(uri, uri_vec.ptr, uri_vec.len) == 0) {
*document_root = path_vec;
len_of_matched_uri = uri_vec.len;
break;
}
}

return len_of_matched_uri;
}

static void convert_uri_to_file_name(struct mg_connection *conn,
const char *uri, char *buf,
size_t buf_len) {
struct vec vec;
int match_len;

match_len = get_document_root(conn, &vec);
mg_snprintf(conn, buf, buf_len, "%.*s%s", vec.len, vec.ptr, uri + match_len);

#if defined(_WIN32) && !defined(__SYMBIAN32__)
change_slashes_to_backslashes(buf);
#endif /* _WIN32 */

DEBUG_TRACE(("[%s] -> [%s], [%.*s]", uri, buf, (int) vec.len, vec.ptr));
}

Original issue reported on code.google.com by fvsfvs...@gmail.com on 29 Dec 2012 at 9:30

GoogleCodeExporter commented 8 years ago
It is my fault, I download it but don't konw other option, I'm so sorry.

Original comment by fvsfvs...@gmail.com on 29 Dec 2012 at 12:53