mirror of
https://github.com/nginx/nginx.git
synced 2024-11-21 16:28:40 +00:00
nginx-0.0.2-2004-03-14-23:46:25 import
This commit is contained in:
parent
67f88e9cc6
commit
3646a1669d
21
auto/cc
21
auto/cc
@ -86,9 +86,17 @@ case $CC in
|
||||
# optimization
|
||||
CFLAGS="$CFLAGS -O"
|
||||
# inline functions declared with __inline
|
||||
CFLAGS="$CFLAGS -Ob1"
|
||||
#CFLAGS="$CFLAGS -Ob1"
|
||||
# inline any function, at the compiler's discretion
|
||||
#CFLAGS="$CFLAGS -Ob2"
|
||||
CFLAGS="$CFLAGS -Ob2"
|
||||
|
||||
# single-file IP optimizations
|
||||
#IPO="-ip"
|
||||
# multi-file IP optimizations
|
||||
IPO="-ipo -ipo_obj"
|
||||
CFLAGS="$CFLAGS $IPO"
|
||||
CORE_LINK="$CORE_LINK $IPO"
|
||||
CORE_LINK="$CORE_LINK -opt_report_file=$OBJS/opt_report_file"
|
||||
|
||||
case $CPU in
|
||||
pentium)
|
||||
@ -110,15 +118,15 @@ case $CC in
|
||||
CFLAGS="$CFLAGS $CPU_OPT"
|
||||
|
||||
if [ ".$PCRE_OPT" = "." ]; then
|
||||
PCRE_OPT="-O $CPU_OPT"
|
||||
PCRE_OPT="-O $IPO $CPU_OPT"
|
||||
fi
|
||||
|
||||
if [ ".$MD5_OPT" = "." ]; then
|
||||
MD5_OPT="-O $CPU_OPT"
|
||||
MD5_OPT="-O $IPO $CPU_OPT"
|
||||
fi
|
||||
|
||||
if [ ".$ZLIB_OPT" = "." ]; then
|
||||
ZLIB_OPT="-O $CPU_OPT"
|
||||
ZLIB_OPT="-O $IPO $CPU_OPT"
|
||||
fi
|
||||
|
||||
# warnings
|
||||
@ -127,6 +135,9 @@ case $CC in
|
||||
# stop on warning
|
||||
CFLAGS="$CFLAGS -Werror"
|
||||
|
||||
# debug
|
||||
CFLAGS="$CFLAGS -g"
|
||||
|
||||
have=HAVE_C99_VARIADIC_MACROS . auto/have
|
||||
|
||||
LINK="\$(CC)"
|
||||
|
@ -25,6 +25,17 @@ if [ $MD5 != NONE ]; then
|
||||
CORE_LIBS="$CORE_LIBS $MD5/md5.lib"
|
||||
;;
|
||||
|
||||
*icc)
|
||||
LINK_DEPS="$LINK_DEPS $MD5/libmd5.a"
|
||||
|
||||
# to allow -ipo optimization we link with the *.o but not library
|
||||
CORE_LIBS="$CORE_LIBS $MD5/md5_dgst.o"
|
||||
|
||||
if [ $MD5_ASM = YES ]; then
|
||||
CORE_LIBS="$CORE_LIBS $MD5/asm/mx86-elf.o"
|
||||
fi
|
||||
;;
|
||||
|
||||
*)
|
||||
LINK_DEPS="$LINK_DEPS $MD5/libmd5.a"
|
||||
CORE_LIBS="$CORE_LIBS -L $MD5 -lmd5"
|
||||
|
@ -9,7 +9,8 @@ if [ $PCRE != NONE ]; then
|
||||
cl)
|
||||
have=HAVE_PCRE . auto/have
|
||||
have=PCRE_STATIC . auto/have
|
||||
CORE_DEPS="$CORE_DEPS $PCRE/pcre.lib"
|
||||
CORE_DEPS="$CORE_DEPS $PCRE/pcre.h"
|
||||
LINK_DEPS="$LINK_DEPS $PCRE/pcre.lib"
|
||||
CORE_LIBS="$CORE_LIBS pcre.lib"
|
||||
CORE_LINK="$CORE_LINK -libpath:$PCRE"
|
||||
;;
|
||||
@ -17,10 +18,24 @@ if [ $PCRE != NONE ]; then
|
||||
wcl386)
|
||||
have=HAVE_PCRE . auto/have
|
||||
have=PCRE_STATIC . auto/have
|
||||
CORE_DEPS="$CORE_DEPS $PCRE/pcre.lib"
|
||||
CORE_DEPS="$CORE_DEPS $PCRE/pcre.h"
|
||||
LINK_DEPS="$LINK_DEPS $PCRE/pcre.lib"
|
||||
CORE_LIBS="$CORE_LIBS $PCRE/pcre.lib"
|
||||
;;
|
||||
|
||||
*icc)
|
||||
have=HAVE_PCRE . auto/have
|
||||
CORE_DEPS="$CORE_DEPS $PCRE/pcre.h"
|
||||
|
||||
LINK_DEPS="$LINK_DEPS $PCRE/.libs/libpcre.a"
|
||||
|
||||
# to allow -ipo optimization we link with the *.o but not library
|
||||
CORE_LIBS="$CORE_LIBS $PCRE/maketables.o"
|
||||
CORE_LIBS="$CORE_LIBS $PCRE/get.o"
|
||||
CORE_LIBS="$CORE_LIBS $PCRE/study.o"
|
||||
CORE_LIBS="$CORE_LIBS $PCRE/pcre.o"
|
||||
;;
|
||||
|
||||
*)
|
||||
have=HAVE_PCRE . auto/have
|
||||
CORE_DEPS="$CORE_DEPS $PCRE/pcre.h"
|
||||
|
@ -19,7 +19,12 @@ case $PLATFORM in
|
||||
cp auto/lib/pcre/patch.config.in $PCRE
|
||||
cp auto/lib/pcre/$makefile $PCRE
|
||||
|
||||
echo "$PCRE/pcre.lib:" >> $MAKEFILE
|
||||
echo "$PCRE/pcre.h:" >> $MAKEFILE
|
||||
echo " cd $PCRE" >> $MAKEFILE
|
||||
echo " \$(MAKE) -f $makefile pcre.h" >> $MAKEFILE
|
||||
echo " cd ..\\..\\.." >> $MAKEFILE
|
||||
echo >> $MAKEFILE
|
||||
echo "$PCRE/pcre.lib: $PCRE/pcre.h" >> $MAKEFILE
|
||||
echo " cd $PCRE" >> $MAKEFILE
|
||||
echo " \$(MAKE) -f $makefile CPU_OPT=$CPU_OPT LIBC=$LIBC">> $MAKEFILE
|
||||
echo " cd ..\\..\\.." >> $MAKEFILE
|
||||
|
@ -3,10 +3,7 @@ CFLAGS = -O2 -Ob1 -Oi -Gs $(LIBC) $(CPU_OPT)
|
||||
PCREFLAGS = -DPCRE_STATIC -DPOSIX_MALLOC_THRESHOLD=10
|
||||
|
||||
|
||||
pcre.lib:
|
||||
patch -o pcre.h pcre.in patch.pcre.in
|
||||
patch -o config.h config.in patch.config.in
|
||||
|
||||
pcre.lib: pcre.h
|
||||
cl -Fedftables dftables.c
|
||||
|
||||
dftables > chartables.c
|
||||
@ -16,3 +13,7 @@ pcre.lib:
|
||||
|
||||
link -lib -out:pcre.lib -verbose:lib \
|
||||
maketables.obj get.obj study.obj pcre.obj
|
||||
|
||||
pcre.h:
|
||||
patch -o pcre.h pcre.in patch.pcre.in
|
||||
patch -o config.h config.in patch.config.in
|
||||
|
@ -3,12 +3,14 @@ CFLAGS = -c -zq -bt=nt -ot -op -oi -oe -s -bm $(CPU_OPT)
|
||||
PCREFLAGS = -DPCRE_STATIC -DPOSIX_MALLOC_THRESHOLD=10
|
||||
|
||||
|
||||
pcre.lib:
|
||||
patch -o pcre.h pcre.in patch.pcre.in
|
||||
patch -o config.h config.in patch.config.in
|
||||
|
||||
pcre.lib: pcre.h
|
||||
wcl386 -zq -bt=nt -l=nt -fe=dftables dftables.c
|
||||
dftables > chartables.c
|
||||
|
||||
wcl386 $(CFLAGS) $(PCREFLAGS) maketables.c get.c study.c pcre.c
|
||||
wlib -n pcre.lib maketables.obj get.obj study.obj pcre.obj
|
||||
|
||||
|
||||
pcre.h:
|
||||
patch -o pcre.h pcre.in patch.pcre.in
|
||||
patch -o config.h config.in patch.config.in
|
||||
|
@ -15,6 +15,21 @@ if [ $ZLIB != NONE ]; then
|
||||
CORE_LIBS="$CORE_LIBS $ZLIB/zlib.lib"
|
||||
;;
|
||||
|
||||
*icc)
|
||||
LINK_DEPS="$LINK_DEPS $ZLIB/libz.a"
|
||||
|
||||
# to allow -ipo optimization we link with the *.o but not library
|
||||
CORE_LIBS="$CORE_LIBS $ZLIB/adler32.o"
|
||||
CORE_LIBS="$CORE_LIBS $ZLIB/crc32.o"
|
||||
CORE_LIBS="$CORE_LIBS $ZLIB/deflate.o"
|
||||
CORE_LIBS="$CORE_LIBS $ZLIB/trees.o"
|
||||
CORE_LIBS="$CORE_LIBS $ZLIB/zutil.o"
|
||||
|
||||
if [ $ZLIB_ASM != NO ]; then
|
||||
CORE_LIBS="$CORE_LIBS $ZLIB/match.o"
|
||||
fi
|
||||
;;
|
||||
|
||||
*)
|
||||
LINK_DEPS="$LINK_DEPS $ZLIB/libz.a"
|
||||
CORE_LIBS="$CORE_LIBS -L $ZLIB -lz"
|
||||
|
@ -225,8 +225,6 @@ HTTP_REWRITE_SRCS=src/http/modules/ngx_http_rewrite_handler.c
|
||||
|
||||
HTTP_GZIP_FILTER_MODULE=ngx_http_gzip_filter_module
|
||||
HTTP_GZIP_SRCS=src/http/modules/ngx_http_gzip_filter.c
|
||||
HTTP_GZIP_UNIX_LIBS=-lz
|
||||
HTTP_GZIP_WIN_LIBS=zlib.lib
|
||||
|
||||
|
||||
HTTP_SSI_FILTER_MODULE=ngx_http_ssi_filter_module
|
||||
|
@ -252,7 +252,9 @@ ngx_int_t ngx_connection_error(ngx_connection_t *c, ngx_err_t err, char *text)
|
||||
#if !(WIN32)
|
||||
|| err == NGX_EPIPE
|
||||
#endif
|
||||
|| err == NGX_ENOTCONN)
|
||||
|| err == NGX_ENOTCONN
|
||||
|| err == NGX_ECONNREFUSED
|
||||
|| err == NGX_EHOSTUNREACH)
|
||||
{
|
||||
|
||||
switch (c->log_error) {
|
||||
|
@ -20,11 +20,6 @@ typedef struct {
|
||||
|
||||
#define ngx_strncasecmp strnicmp
|
||||
#define ngx_strcasecmp stricmp
|
||||
#define ngx_strncmp strncmp
|
||||
#define ngx_strcmp strcmp
|
||||
|
||||
#define ngx_strstr strstr
|
||||
#define ngx_strlen strlen
|
||||
|
||||
#define ngx_snprintf _snprintf
|
||||
#define ngx_vsnprintf _vsnprintf
|
||||
@ -33,20 +28,26 @@ typedef struct {
|
||||
|
||||
#define ngx_strncasecmp strncasecmp
|
||||
#define ngx_strcasecmp strcasecmp
|
||||
#define ngx_strncmp strncmp
|
||||
#define ngx_strcmp strcmp
|
||||
|
||||
#define ngx_strstr strstr
|
||||
#define ngx_strlen strlen
|
||||
|
||||
#define ngx_snprintf snprintf
|
||||
#define ngx_vsnprintf vsnprintf
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#define ngx_strncmp strncmp
|
||||
|
||||
/* msvc and icc compile strcmp() to inline loop */
|
||||
#define ngx_strcmp strcmp
|
||||
|
||||
#define ngx_strstr strstr
|
||||
#define ngx_strlen strlen
|
||||
|
||||
/*
|
||||
* msvc and icc compile memset() to inline "rep stos"
|
||||
* while ZeroMemory and bzero are calls.
|
||||
*
|
||||
* icc can also inline mov's of a zeroed register for small blocks.
|
||||
*/
|
||||
#define ngx_memzero(buf, n) memset(buf, 0, n)
|
||||
|
||||
|
@ -30,11 +30,11 @@ static ngx_command_t ngx_iocp_commands[] = {
|
||||
offsetof(ngx_iocp_conf_t, threads),
|
||||
NULL},
|
||||
|
||||
{ngx_string("acceptex"),
|
||||
{ngx_string("post_acceptex"),
|
||||
NGX_EVENT_CONF|NGX_CONF_TAKE1,
|
||||
ngx_conf_set_num_slot,
|
||||
0,
|
||||
offsetof(ngx_iocp_conf_t, acceptex),
|
||||
offsetof(ngx_iocp_conf_t, post_acceptex),
|
||||
NULL},
|
||||
|
||||
{ngx_string("acceptex_read"),
|
||||
@ -266,7 +266,7 @@ static void *ngx_iocp_create_conf(ngx_cycle_t *cycle)
|
||||
NGX_CONF_ERROR);
|
||||
|
||||
cf->threads = NGX_CONF_UNSET;
|
||||
cf->acceptex = NGX_CONF_UNSET;
|
||||
cf->post_acceptex = NGX_CONF_UNSET;
|
||||
cf->acceptex_read = NGX_CONF_UNSET;
|
||||
|
||||
return cf;
|
||||
@ -278,7 +278,7 @@ static char *ngx_iocp_init_conf(ngx_cycle_t *cycle, void *conf)
|
||||
ngx_iocp_conf_t *cf = conf;
|
||||
|
||||
ngx_conf_init_value(cf->threads, 0);
|
||||
ngx_conf_init_value(cf->acceptex, 10);
|
||||
ngx_conf_init_value(cf->post_acceptex, 10);
|
||||
ngx_conf_init_value(cf->acceptex_read, 1);
|
||||
|
||||
return NGX_CONF_OK;
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
typedef struct {
|
||||
int threads;
|
||||
int acceptex;
|
||||
int post_acceptex;
|
||||
int acceptex_read;
|
||||
} ngx_iocp_conf_t;
|
||||
|
||||
|
@ -264,7 +264,9 @@ static int ngx_event_init(ngx_cycle_t *cycle)
|
||||
}
|
||||
|
||||
iocpcf = ngx_event_get_conf(cycle->conf_ctx, ngx_iocp_module);
|
||||
if (ngx_event_post_acceptex(&s[i], iocpcf->acceptex) == NGX_ERROR) {
|
||||
if (ngx_event_post_acceptex(&s[i], iocpcf->post_acceptex)
|
||||
== NGX_ERROR)
|
||||
{
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
|
@ -179,6 +179,8 @@ int ngx_event_connect_peer(ngx_peer_connection_t *pc)
|
||||
|
||||
c->fd = s;
|
||||
|
||||
c->log_error = pc->log_error;
|
||||
|
||||
pc->connection = c;
|
||||
|
||||
/*
|
||||
@ -212,10 +214,10 @@ int ngx_event_connect_peer(ngx_peer_connection_t *pc)
|
||||
if (rc == -1) {
|
||||
err = ngx_socket_errno;
|
||||
|
||||
/* Winsock returns WSAEWOULDBLOCK */
|
||||
/* Winsock returns WSAEWOULDBLOCK (NGX_EAGAIN) */
|
||||
|
||||
if (err != NGX_EINPROGRESS && err != NGX_EAGAIN) {
|
||||
ngx_log_error(NGX_LOG_ERR, pc->log, err, "connect() failed");
|
||||
ngx_connection_error(c, err, "connect() failed");
|
||||
|
||||
if (ngx_close_socket(s) == -1) {
|
||||
ngx_log_error(NGX_LOG_ALERT, pc->log, ngx_socket_errno,
|
||||
|
@ -47,6 +47,7 @@ typedef struct {
|
||||
ngx_log_t *log;
|
||||
|
||||
unsigned cached:1;
|
||||
unsigned log_error:2; /* ngx_connection_log_error_e */
|
||||
} ngx_peer_connection_t;
|
||||
|
||||
|
||||
|
@ -98,7 +98,6 @@ ngx_module_t ngx_http_index_module = {
|
||||
int ngx_http_index_handler(ngx_http_request_t *r)
|
||||
{
|
||||
char *name;
|
||||
uint32_t crc;
|
||||
size_t len;
|
||||
ngx_fd_t fd;
|
||||
ngx_int_t rc;
|
||||
@ -108,6 +107,9 @@ int ngx_http_index_handler(ngx_http_request_t *r)
|
||||
ngx_http_index_ctx_t *ctx;
|
||||
ngx_http_core_loc_conf_t *clcf;
|
||||
ngx_http_index_loc_conf_t *ilcf;
|
||||
#if (NGX_HTTP_CACHE)
|
||||
uint32_t crc;
|
||||
#endif
|
||||
|
||||
if (r->uri.data[r->uri.len - 1] != '/') {
|
||||
return NGX_DECLINED;
|
||||
|
@ -61,7 +61,6 @@ ngx_module_t ngx_http_static_module = {
|
||||
static ngx_int_t ngx_http_static_handler(ngx_http_request_t *r)
|
||||
{
|
||||
char *last;
|
||||
uint32_t file_crc, redirect_crc;
|
||||
ngx_fd_t fd;
|
||||
ngx_int_t rc;
|
||||
ngx_uint_t level;
|
||||
@ -71,11 +70,14 @@ static ngx_int_t ngx_http_static_handler(ngx_http_request_t *r)
|
||||
ngx_hunk_t *h;
|
||||
ngx_chain_t out;
|
||||
ngx_file_info_t fi;
|
||||
ngx_http_cache_t *file, *redirect;
|
||||
ngx_http_cleanup_t *file_cleanup, *redirect_cleanup;
|
||||
ngx_http_log_ctx_t *ctx;
|
||||
ngx_http_core_loc_conf_t *clcf;
|
||||
ngx_http_static_loc_conf_t *slcf;
|
||||
#if (NGX_HTTP_CACHE)
|
||||
uint32_t file_crc, redirect_crc;
|
||||
ngx_http_cache_t *file, *redirect;
|
||||
#endif
|
||||
|
||||
if (r->uri.data[r->uri.len - 1] == '/') {
|
||||
return NGX_DECLINED;
|
||||
|
@ -81,6 +81,13 @@ static ngx_command_t ngx_http_proxy_commands[] = {
|
||||
offsetof(ngx_http_proxy_loc_conf_t, send_timeout),
|
||||
NULL },
|
||||
|
||||
{ ngx_string("proxy_preserve_host"),
|
||||
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
|
||||
ngx_conf_set_flag_slot,
|
||||
NGX_HTTP_LOC_CONF_OFFSET,
|
||||
offsetof(ngx_http_proxy_loc_conf_t, preserve_host),
|
||||
NULL },
|
||||
|
||||
{ ngx_string("proxy_set_x_real_ip"),
|
||||
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
|
||||
ngx_conf_set_flag_slot,
|
||||
@ -774,6 +781,7 @@ static void *ngx_http_proxy_create_loc_conf(ngx_conf_t *cf)
|
||||
conf->connect_timeout = NGX_CONF_UNSET;
|
||||
conf->send_timeout = NGX_CONF_UNSET;
|
||||
|
||||
conf->preserve_host = NGX_CONF_UNSET;
|
||||
conf->set_x_real_ip = NGX_CONF_UNSET;
|
||||
conf->add_x_forwarded_for = NGX_CONF_UNSET;
|
||||
|
||||
@ -816,6 +824,7 @@ static char *ngx_http_proxy_merge_loc_conf(ngx_conf_t *cf,
|
||||
prev->connect_timeout, 60000);
|
||||
ngx_conf_merge_msec_value(conf->send_timeout, prev->send_timeout, 30000);
|
||||
|
||||
ngx_conf_merge_value(conf->preserve_host, prev->preserve_host, 0);
|
||||
ngx_conf_merge_value(conf->set_x_real_ip, prev->set_x_real_ip, 0);
|
||||
ngx_conf_merge_value(conf->add_x_forwarded_for,
|
||||
prev->add_x_forwarded_for, 0);
|
||||
@ -1057,6 +1066,7 @@ static char *ngx_http_proxy_parse_upstream(ngx_str_t *url,
|
||||
}
|
||||
|
||||
if (u->port_text.data == NULL) {
|
||||
u->default_port = 1;
|
||||
u->port = htons(80);
|
||||
u->port_text.len = 2;
|
||||
u->port_text.data = "80";
|
||||
@ -1087,6 +1097,7 @@ static char *ngx_http_proxy_parse_upstream(ngx_str_t *url,
|
||||
u->uri.len = 1;
|
||||
|
||||
if (u->port_text.data == NULL) {
|
||||
u->default_port = 1;
|
||||
u->port = htons(80);
|
||||
u->port_text.len = 2;
|
||||
u->port_text.data = "80";
|
||||
|
@ -41,6 +41,7 @@ typedef struct {
|
||||
ngx_str_t port_text;
|
||||
ngx_str_t *location;
|
||||
int port;
|
||||
unsigned default_port:1;
|
||||
} ngx_http_proxy_upstream_conf_t;
|
||||
|
||||
|
||||
@ -60,6 +61,7 @@ typedef struct {
|
||||
|
||||
ngx_flag_t cache;
|
||||
|
||||
ngx_flag_t preserve_host;
|
||||
ngx_flag_t set_x_real_ip;
|
||||
ngx_flag_t add_x_forwarded_for;
|
||||
|
||||
|
@ -57,6 +57,7 @@ int ngx_http_proxy_request_upstream(ngx_http_proxy_ctx_t *p)
|
||||
|
||||
p->upstream = u;
|
||||
|
||||
u->peer.log_error = NGX_ERROR_ERR;
|
||||
u->peer.peers = p->lcf->peers;
|
||||
u->peer.tries = p->lcf->peers->number;
|
||||
|
||||
@ -113,21 +114,29 @@ static ngx_chain_t *ngx_http_proxy_create_request(ngx_http_proxy_ctx_t *p)
|
||||
+ r->uri.len - uc->location->len
|
||||
+ 1 + r->args.len /* 1 is for "?" */
|
||||
+ sizeof(http_version) - 1
|
||||
+ sizeof(host_header) - 1 + uc->host_header.len + 2
|
||||
/* 2 is for "\r\n" */
|
||||
+ sizeof(connection_close_header) - 1
|
||||
+ 2; /* 2 is for "\r\n" at the header end */
|
||||
|
||||
if (p->lcf->set_x_real_ip) {
|
||||
/* 2 is for "\r\n" */
|
||||
|
||||
if (p->lcf->preserve_host) {
|
||||
len += sizeof(host_header) - 1
|
||||
+ r->headers_in.host_name_len
|
||||
+ 1 /* 1 is for ":" */
|
||||
+ uc->port_text.len
|
||||
+ 2; /* 2 is for "\r\n" */
|
||||
} else { /* 2 is for "\r\n" */
|
||||
len += sizeof(host_header) - 1 + uc->host_header.len + 2;
|
||||
}
|
||||
|
||||
|
||||
if (p->lcf->set_x_real_ip) { /* 2 is for "\r\n" */
|
||||
len += sizeof(x_real_ip_header) - 1 + INET_ADDRSTRLEN - 1 + 2;
|
||||
}
|
||||
|
||||
|
||||
if (p->lcf->add_x_forwarded_for) {
|
||||
if (r->headers_in.x_forwarded_for) {
|
||||
len += r->headers_in.x_forwarded_for->key.len
|
||||
+ 2 /* 2 is ofr ": " */
|
||||
len += sizeof(x_forwarded_for_header) - 1
|
||||
+ r->headers_in.x_forwarded_for->value.len
|
||||
+ 2 /* 2 is ofr ", " */
|
||||
+ INET_ADDRSTRLEN - 1
|
||||
@ -179,19 +188,33 @@ static ngx_chain_t *ngx_http_proxy_create_request(ngx_http_proxy_ctx_t *p)
|
||||
h->last = ngx_cpymem(h->last, http_version, sizeof(http_version) - 1);
|
||||
|
||||
|
||||
/* the "Host" header */
|
||||
|
||||
h->last = ngx_cpymem(h->last, host_header, sizeof(host_header) - 1);
|
||||
h->last = ngx_cpymem(h->last, uc->host_header.data, uc->host_header.len);
|
||||
*(h->last++) = CR; *(h->last++) = LF;
|
||||
|
||||
|
||||
/* the "Connection: close" header */
|
||||
|
||||
h->last = ngx_cpymem(h->last, connection_close_header,
|
||||
sizeof(connection_close_header) - 1);
|
||||
|
||||
|
||||
/* the "Host" header */
|
||||
|
||||
h->last = ngx_cpymem(h->last, host_header, sizeof(host_header) - 1);
|
||||
|
||||
if (p->lcf->preserve_host) {
|
||||
h->last = ngx_cpymem(h->last, r->headers_in.host->value.data,
|
||||
r->headers_in.host_name_len);
|
||||
|
||||
if (!uc->default_port) {
|
||||
*(h->last++) = ':';
|
||||
h->last = ngx_cpymem(h->last, uc->port_text.data,
|
||||
uc->port_text.len);
|
||||
}
|
||||
|
||||
} else {
|
||||
h->last = ngx_cpymem(h->last, uc->host_header.data,
|
||||
uc->host_header.len);
|
||||
}
|
||||
*(h->last++) = CR; *(h->last++) = LF;
|
||||
|
||||
|
||||
/* the "X-Real-IP" header */
|
||||
|
||||
if (p->lcf->set_x_real_ip) {
|
||||
@ -207,11 +230,8 @@ static ngx_chain_t *ngx_http_proxy_create_request(ngx_http_proxy_ctx_t *p)
|
||||
|
||||
if (p->lcf->add_x_forwarded_for) {
|
||||
if (r->headers_in.x_forwarded_for) {
|
||||
h->last = ngx_cpymem(h->last,
|
||||
r->headers_in.x_forwarded_for->key.data,
|
||||
r->headers_in.x_forwarded_for->key.len);
|
||||
|
||||
*(h->last++) = ':'; *(h->last++) = ' ';
|
||||
h->last = ngx_cpymem(h->last, x_forwarded_for_header,
|
||||
sizeof(x_forwarded_for_header) - 1);
|
||||
|
||||
h->last = ngx_cpymem(h->last,
|
||||
r->headers_in.x_forwarded_for->value.data,
|
||||
@ -416,7 +436,10 @@ static void ngx_http_proxy_reinit_upstream(ngx_http_proxy_ctx_t *p)
|
||||
|
||||
void ngx_http_proxy_upstream_busy_lock(ngx_http_proxy_ctx_t *p)
|
||||
{
|
||||
int rc, ft_type;
|
||||
ngx_int_t rc;
|
||||
#if (NGX_HTTP_CACHE)
|
||||
ngx_int_t ft_type;
|
||||
#endif
|
||||
|
||||
if (p->busy_lock.time == 0) {
|
||||
p->busy_lock.event = p->request->connection->read;
|
||||
@ -436,6 +459,8 @@ void ngx_http_proxy_upstream_busy_lock(ngx_http_proxy_ctx_t *p)
|
||||
|
||||
ngx_http_busy_unlock(p->lcf->busy_lock, &p->busy_lock);
|
||||
|
||||
#if (NGX_HTTP_CACHE)
|
||||
|
||||
if (rc == NGX_DONE) {
|
||||
ft_type = NGX_HTTP_PROXY_FT_BUSY_LOCK;
|
||||
|
||||
@ -444,8 +469,6 @@ void ngx_http_proxy_upstream_busy_lock(ngx_http_proxy_ctx_t *p)
|
||||
ft_type = NGX_HTTP_PROXY_FT_MAX_WAITING;
|
||||
}
|
||||
|
||||
#if (NGX_HTTP_CACHE)
|
||||
|
||||
if (p->stale && (p->lcf->use_stale & ft_type)) {
|
||||
ngx_http_proxy_finalize_request(p,
|
||||
ngx_http_proxy_send_cached_response(p));
|
||||
@ -1067,13 +1090,13 @@ static void ngx_http_proxy_send_response(ngx_http_proxy_ctx_t *p)
|
||||
ep->pool = r->pool;
|
||||
ep->log = r->connection->log;
|
||||
|
||||
ep->cachable = p->cachable;
|
||||
|
||||
if (!(ep->temp_file = ngx_pcalloc(r->pool, sizeof(ngx_temp_file_t)))) {
|
||||
ngx_http_proxy_finalize_request(p, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
ep->cachable = p->cachable;
|
||||
|
||||
ep->temp_file->file.fd = NGX_INVALID_FILE;
|
||||
ep->temp_file->file.log = r->connection->log;
|
||||
ep->temp_file->path = p->lcf->temp_path;
|
||||
|
@ -23,6 +23,8 @@ typedef int ngx_err_t;
|
||||
#define NGX_ECONNRESET ECONNRESET
|
||||
#define NGX_ENOTCONN ENOTCONN
|
||||
#define NGX_ETIMEDOUT ETIMEDOUT
|
||||
#define NGX_ECONNREFUSED ECONNREFUSED
|
||||
#define NGX_EHOSTUNREACH EHOSTUNREACH
|
||||
#define NGX_ECANCELED ECANCELED
|
||||
#define NGX_ENOMOREFILES 0
|
||||
|
||||
|
@ -25,6 +25,8 @@ typedef DWORD ngx_err_t;
|
||||
#define NGX_ECONNRESET WSAECONNRESET
|
||||
#define NGX_ENOTCONN WSAENOTCONN
|
||||
#define NGX_ETIMEDOUT WSAETIMEDOUT
|
||||
#define NGX_ECONNREFUSED WSAECONNREFUSED
|
||||
#define NGX_EHOSTUNREACH WSAEHOSTUNREACH
|
||||
#define NGX_ENOMOREFILES ERROR_NO_MORE_FILES
|
||||
|
||||
#define NGX_EALREADY WSAEALREADY
|
||||
|
Loading…
Reference in New Issue
Block a user