Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nginx/nginx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src/http
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2004-08-31 19:32:52 +0400
committerIgor Sysoev <igor@sysoev.ru>2004-08-31 19:32:52 +0400
commit13836ce3e6a22c3c58b4696c1ec1d753dff57237 (patch)
tree74880a5cc6e592c952648d7d36077c86a0be13cc /src/http
parent7105763f5b353df35505bec6598baf2830583c26 (diff)
nginx-0.0.10-2004-08-31-19:32:52 import
Diffstat (limited to 'src/http')
-rw-r--r--src/http/modules/ngx_http_gzip_filter.c14
-rw-r--r--src/http/modules/ngx_http_userid_filter.c67
-rw-r--r--src/http/modules/proxy/ngx_http_proxy_upstream.c28
3 files changed, 75 insertions, 34 deletions
diff --git a/src/http/modules/ngx_http_gzip_filter.c b/src/http/modules/ngx_http_gzip_filter.c
index 5c6d0d12d..611f157ef 100644
--- a/src/http/modules/ngx_http_gzip_filter.c
+++ b/src/http/modules/ngx_http_gzip_filter.c
@@ -122,42 +122,42 @@ static ngx_command_t ngx_http_gzip_filter_commands[] = {
ngx_conf_set_flag_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_gzip_conf_t, enable),
- NULL},
+ NULL },
{ ngx_string("gzip_buffers"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE2,
ngx_conf_set_bufs_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_gzip_conf_t, bufs),
- NULL},
+ NULL },
{ ngx_string("gzip_comp_level"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
ngx_conf_set_num_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_gzip_conf_t, level),
- &ngx_http_gzip_comp_level_bounds},
+ &ngx_http_gzip_comp_level_bounds },
{ ngx_string("gzip_window"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
ngx_conf_set_size_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_gzip_conf_t, wbits),
- &ngx_http_gzip_set_window_p},
+ &ngx_http_gzip_set_window_p },
{ ngx_string("gzip_hash"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
ngx_conf_set_size_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_gzip_conf_t, memlevel),
- &ngx_http_gzip_set_hash_p},
+ &ngx_http_gzip_set_hash_p },
{ ngx_string("gzip_no_buffer"),
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_gzip_conf_t, no_buffer),
- NULL},
+ NULL },
{ ngx_string("gzip_http_version"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_ANY,
@@ -178,7 +178,7 @@ static ngx_command_t ngx_http_gzip_filter_commands[] = {
ngx_conf_set_size_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_gzip_conf_t, min_length),
- NULL},
+ NULL },
ngx_null_command
};
diff --git a/src/http/modules/ngx_http_userid_filter.c b/src/http/modules/ngx_http_userid_filter.c
index 8fc6a94bd..ba0d5838e 100644
--- a/src/http/modules/ngx_http_userid_filter.c
+++ b/src/http/modules/ngx_http_userid_filter.c
@@ -51,6 +51,7 @@ static ngx_int_t ngx_http_userid_pre_conf(ngx_conf_t *cf);
static void *ngx_http_userid_create_conf(ngx_conf_t *cf);
static char *ngx_http_userid_merge_conf(ngx_conf_t *cf, void *parent,
void *child);
+char *ngx_conf_check_domain(ngx_conf_t *cf, void *post, void *data);
char *ngx_http_userid_expires(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
@@ -73,6 +74,10 @@ static ngx_conf_enum_t ngx_http_userid_state[] = {
};
+static ngx_conf_post_handler_pt ngx_conf_check_domain_p =
+ ngx_conf_check_domain;
+
+
static ngx_command_t ngx_http_userid_commands[] = {
{ ngx_string("userid"),
@@ -80,42 +85,42 @@ static ngx_command_t ngx_http_userid_commands[] = {
ngx_conf_set_enum_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_userid_conf_t, enable),
- ngx_http_userid_state},
+ ngx_http_userid_state },
{ ngx_string("userid_service"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
ngx_conf_set_num_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_userid_conf_t, service),
- NULL},
+ NULL },
{ ngx_string("userid_name"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
ngx_conf_set_str_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_userid_conf_t, name),
- NULL},
+ NULL },
{ ngx_string("userid_domain"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
ngx_conf_set_str_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_userid_conf_t, domain),
- NULL},
+ &ngx_conf_check_domain_p },
{ ngx_string("userid_path"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
ngx_conf_set_str_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_userid_conf_t, path),
- NULL},
+ NULL },
{ ngx_string("userid_expires"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
ngx_http_userid_expires,
NGX_HTTP_LOC_CONF_OFFSET,
0,
- NULL},
+ NULL },
ngx_null_command
};
@@ -165,8 +170,7 @@ static ngx_int_t ngx_http_userid_filter(ngx_http_request_t *r)
}
ngx_http_create_ctx(r, ctx, ngx_http_userid_filter_module,
- sizeof(ngx_http_userid_ctx_t),
- NGX_HTTP_INTERNAL_SERVER_ERROR);
+ sizeof(ngx_http_userid_ctx_t), NGX_ERROR);
rc = ngx_http_userid_get_uid(r, ctx, conf);
@@ -174,8 +178,8 @@ static ngx_int_t ngx_http_userid_filter(ngx_http_request_t *r)
return rc;
}
- if (conf->enable == NGX_HTTP_USERID_LOG /* || ctx->uid_got[3] != 0 */) {
- return NGX_OK;
+ if (conf->enable == NGX_HTTP_USERID_LOG || ctx->uid_got[3] != 0) {
+ return ngx_http_next_header_filter(r);
}
rc = ngx_http_userid_set_uid(r, ctx, conf);
@@ -276,11 +280,13 @@ static ngx_int_t ngx_http_userid_set_uid(ngx_http_request_t *r,
ngx_http_userid_conf_t *conf)
{
- u_char *cookie, *p;
- size_t len;
- uint32_t service;
- ngx_str_t src, dst;
- ngx_table_elt_t *set_cookie;
+ u_char *cookie, *p;
+ size_t len;
+ socklen_t slen;
+ struct sockaddr_in addr_in;
+ uint32_t service;
+ ngx_str_t src, dst;
+ ngx_table_elt_t *set_cookie;
/* TODO: mutex for sequencers */
@@ -298,7 +304,21 @@ static ngx_int_t ngx_http_userid_set_uid(ngx_http_request_t *r,
} else {
if (conf->service == NGX_CONF_UNSET) {
+ if (r->in_addr == 0) {
+ slen = sizeof(struct sockaddr_in);
+ if (getsockname(r->connection->fd,
+ (struct sockaddr *) &addr_in, &slen) == -1)
+ {
+ ngx_log_error(NGX_LOG_CRIT, r->connection->log,
+ ngx_socket_errno,
+ "getsockname() failed");
+ }
+
+ r->in_addr = addr_in.sin_addr.s_addr;
+ }
+
ctx->uid_set[0] = htonl(r->in_addr);
+
} else {
ctx->uid_set[0] = htonl(conf->service);
}
@@ -327,7 +347,7 @@ static ngx_int_t ngx_http_userid_set_uid(ngx_http_request_t *r,
}
if (!(cookie = ngx_palloc(r->pool, len))) {
- return NGX_HTTP_INTERNAL_SERVER_ERROR;
+ return NGX_ERROR;
}
p = ngx_cpymem(cookie, conf->name.data, conf->name.len);
@@ -366,7 +386,7 @@ static ngx_int_t ngx_http_userid_set_uid(ngx_http_request_t *r,
set_cookie = ngx_http_add_header(&r->headers_out, ngx_http_headers_out);
if (set_cookie == NULL) {
- return NGX_HTTP_INTERNAL_SERVER_ERROR;
+ return NGX_ERROR;
}
set_cookie->key.len = sizeof("Set-Cookie") - 1;
@@ -520,6 +540,19 @@ static char *ngx_http_userid_merge_conf(ngx_conf_t *cf, void *parent,
}
+char *ngx_conf_check_domain(ngx_conf_t *cf, void *post, void *data)
+{
+ ngx_str_t *domain = data;
+
+ if (domain->len == 4 && ngx_strcmp(domain->data, "none") == 0) {
+ domain->len = 1;
+ domain->data = ".";
+ }
+
+ return NGX_CONF_OK;
+}
+
+
char *ngx_http_userid_expires(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
ngx_http_userid_conf_t *ucf = conf;
diff --git a/src/http/modules/proxy/ngx_http_proxy_upstream.c b/src/http/modules/proxy/ngx_http_proxy_upstream.c
index 80759aebf..8ac6d506a 100644
--- a/src/http/modules/proxy/ngx_http_proxy_upstream.c
+++ b/src/http/modules/proxy/ngx_http_proxy_upstream.c
@@ -617,18 +617,25 @@ static void ngx_http_proxy_connect(ngx_http_proxy_ctx_t *p)
}
if (r->request_body->buf) {
- if (!(output->free = ngx_alloc_chain_link(r->pool))) {
- ngx_http_proxy_finalize_request(p, NGX_HTTP_INTERNAL_SERVER_ERROR);
- return;
- }
+ if (r->request_body->temp_file->file.fd != NGX_INVALID_FILE) {
+
+ if (!(output->free = ngx_alloc_chain_link(r->pool))) {
+ ngx_http_proxy_finalize_request(p,
+ NGX_HTTP_INTERNAL_SERVER_ERROR);
+ return;
+ }
+
+ output->free->buf = r->request_body->buf;
+ output->free->next = NULL;
+ output->allocated = 1;
- output->free->buf = r->request_body->buf;
- output->free->next = NULL;
- output->allocated = 1;
+ r->request_body->buf->pos = r->request_body->buf->start;
+ r->request_body->buf->last = r->request_body->buf->start;
+ r->request_body->buf->tag = (ngx_buf_tag_t) &ngx_http_proxy_module;
- r->request_body->buf->pos = r->request_body->buf->start;
- r->request_body->buf->last = r->request_body->buf->start;
- r->request_body->buf->tag = (ngx_buf_tag_t) &ngx_http_proxy_module;
+ } else {
+ r->request_body->buf->pos = r->request_body->buf->start;
+ }
}
p->request_sent = 0;
@@ -647,6 +654,7 @@ static void ngx_http_proxy_connect(ngx_http_proxy_ctx_t *p)
ngx_http_proxy_process_upstream_status_line(c->read);
return;
}
+
#endif
ngx_http_proxy_send_request(p);