changed httpd to accept http://name:port and https://name:port as a document root value

This commit is contained in:
hyung-hwan 2014-10-17 14:15:15 +00:00
parent c4df310ee7
commit a842cf0767
2 changed files with 23 additions and 1 deletions

View File

@ -157,12 +157,15 @@ struct loccfg_t
ROOT_TYPE_PATH = 0,
ROOT_TYPE_NWAD,
ROOT_TYPE_NWAD_SECURE,
ROOT_TYPE_HOST,
ROOT_TYPE_HOST_SECURE,
ROOT_TYPE_RELOC,
ROOT_TYPE_ERROR
} root_type;
union
{
qse_nwad_t nwad;
const qse_mchar_t* host;
int error_code;
qse_httpd_rsrc_reloc_t reloc;
} root;
@ -611,6 +614,16 @@ printf ("qpath ===> [%s]\n",qpath);
goto proxy_ok;
case ROOT_TYPE_HOST_SECURE:
root->u.proxy.flags |= QSE_HTTPD_RSRC_PROXY_DST_SECURE;
case ROOT_TYPE_HOST:
root->type = QSE_HTTPD_SERVERSTD_ROOT_PROXY;
root->u.proxy.dst.str = loccfg->root.host;
root->u.proxy.flags |= QSE_HTTPD_RSRC_PROXY_DST_STR;
if (loccfg->proxy.pseudonym[0])
root->u.proxy.pseudonym = loccfg->proxy.pseudonym;
goto proxy_ok;
case ROOT_TYPE_RELOC:
root->type = QSE_HTTPD_SERVERSTD_ROOT_RELOC;
root->u.reloc.flags = loccfg->root.reloc.flags;
@ -1759,6 +1772,13 @@ static int load_loccfg (qse_httpd_t* httpd, qse_xli_t* xli, qse_xli_list_t* list
cfg->root_type = (proto_len == 8)? ROOT_TYPE_NWAD_SECURE: ROOT_TYPE_NWAD;
goto done;
}
else if (proto_len > 0 && *root != QSE_MT('\0'))
{
/* it begins with http:// or https:// */
cfg->root_type = (proto_len == 8)? ROOT_TYPE_HOST_SECURE: ROOT_TYPE_HOST;
cfg->root.host = root;
goto done;
}
}
done:

View File

@ -29,6 +29,8 @@ server-default {
####################################################################
root = "/var/www";
#root = "1.2.3.4:80";
#root = "https://1.2.3.4";
#root = "http://code.abiyo.net";
#root = "<302>http://www.google.com"; #301, 302, 303, 307, 308
#root = "<404>"; #400 - 599