mirror of
https://github.com/nginx/nginx.git
synced 2024-12-12 02:09:04 +08:00
nginx-0.0.1-2003-01-29-20:02:48 import
This commit is contained in:
parent
fe5cb6b9e9
commit
1b8b119932
@ -348,6 +348,7 @@ static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, char *dummy)
|
|||||||
ls->ctx = ctx;
|
ls->ctx = ctx;
|
||||||
ls->servers = &in_port[p];
|
ls->servers = &in_port[p];
|
||||||
|
|
||||||
|
#if 0
|
||||||
if (in_port[p].addr.nelts == 1) {
|
if (in_port[p].addr.nelts == 1) {
|
||||||
in_addr = (ngx_http_in_addr_t *) in_port[p].addr.elts;
|
in_addr = (ngx_http_in_addr_t *) in_port[p].addr.elts;
|
||||||
|
|
||||||
@ -359,10 +360,24 @@ static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, char *dummy)
|
|||||||
ls->servers = NULL;
|
ls->servers = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
ngx_log_debug(cf->log, "ls ctx: %d:%08x" _ in_port[p].port _ ls->ctx);
|
ngx_log_debug(cf->log, "ls ctx: %d:%08x" _ in_port[p].port _ ls->ctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* DEBUG STUFF */
|
||||||
|
in_port = (ngx_http_in_port_t *) in_ports.elts;
|
||||||
|
for (p = 0; p < in_ports.nelts; p++) {
|
||||||
|
ngx_log_debug(cf->log, "port: %d" _ in_port[p].port);
|
||||||
|
in_addr = (ngx_http_in_addr_t *) in_port[p].addr.elts;
|
||||||
|
for (a = 0; a < in_port[p].addr.nelts; a++) {
|
||||||
|
char ip[20];
|
||||||
|
ngx_inet_ntop(AF_INET, &in_addr[a].addr, ip, 20);
|
||||||
|
ngx_log_debug(cf->log, "%s %08x" _ ip _ in_addr[a].core_srv_conf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**/
|
||||||
|
|
||||||
return NGX_CONF_OK;
|
return NGX_CONF_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,12 +138,15 @@ struct ngx_http_request_s {
|
|||||||
|
|
||||||
ngx_connection_t *connection;
|
ngx_connection_t *connection;
|
||||||
|
|
||||||
u_int in_addr;
|
u_int in_addr;
|
||||||
|
|
||||||
int filter;
|
int port;
|
||||||
|
ngx_str_t port_name;
|
||||||
|
|
||||||
ssize_t client_content_length;
|
int filter;
|
||||||
char *discarded_buffer;
|
|
||||||
|
ssize_t client_content_length;
|
||||||
|
char *discarded_buffer;
|
||||||
|
|
||||||
ngx_str_t path;
|
ngx_str_t path;
|
||||||
int path_err;
|
int path_err;
|
||||||
|
@ -117,13 +117,13 @@ ngx_log_debug(r->connection->log, "servers: %0x" _ r->connection->servers);
|
|||||||
/* AF_INET only */
|
/* AF_INET only */
|
||||||
|
|
||||||
in_port = (ngx_http_in_port_t *) r->connection->servers;
|
in_port = (ngx_http_in_port_t *) r->connection->servers;
|
||||||
|
in_addr = (ngx_http_in_addr_t *) in_port->addr.elts;
|
||||||
|
|
||||||
a = 0;
|
a = 0;
|
||||||
|
|
||||||
if (in_port->addr.nelts > 1) {
|
if (in_port->addr.nelts > 1) {
|
||||||
/* find r->in_addr, getsockname() */
|
/* find r->in_addr, getsockname() */
|
||||||
|
|
||||||
in_addr = (ngx_http_in_addr_t *) in_port->addr.elts;
|
|
||||||
for ( /* void */ ; a < in_port->addr.nelts; a++) {
|
for ( /* void */ ; a < in_port->addr.nelts; a++) {
|
||||||
|
|
||||||
if (in_addr[a].addr == INADDR_ANY) {
|
if (in_addr[a].addr == INADDR_ANY) {
|
||||||
@ -203,7 +203,7 @@ ngx_log_debug(r->connection->log, "loc_conf: %0x" _ r->loc_conf);
|
|||||||
|
|
||||||
int ngx_http_core_translate_handler(ngx_http_request_t *r)
|
int ngx_http_core_translate_handler(ngx_http_request_t *r)
|
||||||
{
|
{
|
||||||
int i, rc, len, f_offset, l_offset;
|
int i, rc, len, port_len, f_offset, l_offset;
|
||||||
char *buf, *location, *last;
|
char *buf, *location, *last;
|
||||||
ngx_err_t err;
|
ngx_err_t err;
|
||||||
ngx_table_elt_t *h;
|
ngx_table_elt_t *h;
|
||||||
@ -245,14 +245,34 @@ ngx_log_debug(r->connection->log, "doc_root: %08x" _ &loc_conf->doc_root);
|
|||||||
|
|
||||||
s_name = (ngx_http_server_name_t *) scf->server_names.elts;
|
s_name = (ngx_http_server_name_t *) scf->server_names.elts;
|
||||||
|
|
||||||
|
if (r->port == 0) {
|
||||||
|
#if 0
|
||||||
|
struct sockaddr_in *addr_in;
|
||||||
|
addr_in = (struct sockaddr_in *) r->connection->sockaddr;
|
||||||
|
r->port = ntohs(addr_in->sin_port);
|
||||||
|
#else
|
||||||
|
ngx_http_in_port_t *in_port;
|
||||||
|
in_port = (ngx_http_in_port_t *) r->connection->servers;
|
||||||
|
r->port = in_port->port;
|
||||||
|
#endif
|
||||||
|
if (r->port != 80) {
|
||||||
|
ngx_test_null(r->port_name.data, ngx_palloc(r->pool, 7),
|
||||||
|
NGX_HTTP_INTERNAL_SERVER_ERROR);
|
||||||
|
r->port_name.len = ngx_snprintf(r->port_name.data, 7, ":%d",
|
||||||
|
r->port);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
port_len = (r->port != 80) ? r->port_name.len : 0;
|
||||||
|
|
||||||
/* "+ 7" is "http://" */
|
/* "+ 7" is "http://" */
|
||||||
if (loc_conf->doc_root.len > s_name[0].name.len + 7) {
|
if (loc_conf->doc_root.len > 7 + s_name[0].name.len + port_len) {
|
||||||
len = loc_conf->doc_root.len;
|
len = loc_conf->doc_root.len;
|
||||||
f_offset = 0;
|
f_offset = 0;
|
||||||
l_offset = len - (s_name[0].name.len + 7);
|
l_offset = len - (7 + s_name[0].name.len + port_len);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
len = s_name[0].name.len + 7;
|
len = 7 + s_name[0].name.len + port_len;
|
||||||
f_offset = len - loc_conf->doc_root.len;
|
f_offset = len - loc_conf->doc_root.len;
|
||||||
l_offset = 0;
|
l_offset = 0;
|
||||||
}
|
}
|
||||||
@ -367,6 +387,10 @@ ngx_log_debug(r->connection->log, "HTTP DIR: '%s'" _ r->file.name.data);
|
|||||||
|
|
||||||
ngx_memcpy(location, "http://", 7);
|
ngx_memcpy(location, "http://", 7);
|
||||||
ngx_memcpy(location + 7, s_name[0].name.data, s_name[0].name.len);
|
ngx_memcpy(location + 7, s_name[0].name.data, s_name[0].name.len);
|
||||||
|
if (port_len) {
|
||||||
|
ngx_memcpy(location + 7 + s_name[0].name.len, r->port_name.data,
|
||||||
|
port_len);
|
||||||
|
}
|
||||||
|
|
||||||
*last++ = '/';
|
*last++ = '/';
|
||||||
*last = '\0';
|
*last = '\0';
|
||||||
|
Loading…
Reference in New Issue
Block a user