Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why does not support virtual directory in version 3.4 #391

Open
GoogleCodeExporter opened this issue Mar 16, 2015 · 1 comment
Open

Why does not support virtual directory in version 3.4 #391

GoogleCodeExporter opened this issue Mar 16, 2015 · 1 comment

Comments

@GoogleCodeExporter
Copy link

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 [email protected] on 29 Dec 2012 at 9:30

@GoogleCodeExporter
Copy link
Author

It is my fault, I download it but don't konw other option, I'm so sorry.

Original comment by [email protected] on 29 Dec 2012 at 12:53

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant