Mercurial > hg > nginx-quic
changeset 412:199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 31 Aug 2004 15:32:52 +0000 |
parents | 4765ded59eaa |
children | de9d4726e28a |
files | src/core/ngx_conf_file.c src/http/modules/ngx_http_gzip_filter.c src/http/modules/ngx_http_userid_filter.c src/http/modules/proxy/ngx_http_proxy_upstream.c |
diffstat | 4 files changed, 82 insertions(+), 35 deletions(-) [+] |
line wrap: on
line diff
--- a/src/core/ngx_conf_file.c +++ b/src/core/ngx_conf_file.c @@ -663,7 +663,8 @@ char *ngx_conf_set_str_slot(ngx_conf_t * { char *p = conf; - ngx_str_t *field, *value; + ngx_str_t *field, *value; + ngx_conf_post_t *post; field = (ngx_str_t *) (p + cmd->offset); @@ -675,6 +676,11 @@ char *ngx_conf_set_str_slot(ngx_conf_t * *field = value[1]; + if (cmd->post) { + post = cmd->post; + return post->post_handler(cf, post, field); + } + return NGX_CONF_OK; }
--- 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_filt 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_filt ngx_conf_set_size_slot, NGX_HTTP_LOC_CONF_OFFSET, offsetof(ngx_http_gzip_conf_t, min_length), - NULL}, + NULL }, ngx_null_command };
--- 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_con 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_ }; +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_co 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_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( 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_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 } 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 } 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 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( } +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;
--- 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_h } 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_h ngx_http_proxy_process_upstream_status_line(c->read); return; } + #endif ngx_http_proxy_send_request(p);