nginx-0.0.9-2004-07-30-21:05:14 import

This commit is contained in:
Igor Sysoev 2004-07-30 17:05:14 +00:00
parent 00d433f4f8
commit 6deb041b2f
4 changed files with 91 additions and 1 deletions

View File

@ -206,7 +206,7 @@ ngx_int_t ngx_ptocidr(ngx_str_t *text, void *cidr)
return NGX_OK;
}
in_cidr->mask = (ngx_uint_t) (0 - (1 << (32 - m)));
in_cidr->mask = htonl((ngx_uint_t) (0 - (1 << (32 - m))));
return NGX_OK;
}

View File

@ -123,6 +123,83 @@ void ngx_md5_text(u_char *text, u_char *md5)
}
ngx_int_t ngx_encode_base64(ngx_pool_t *pool, ngx_str_t *src, ngx_str_t *dst)
{
u_char *d, *s;
ngx_uint_t i;
static u_char basis64[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
if (!(d = ngx_palloc(pool, ((src->len + 2) / 3) * 4 + 1))) {
return NGX_ERROR;
}
dst->data = d;
s = src->data;
for (i = 0; i < src->len - 2; i += 3) {
*d++ = basis64[(s[i] >> 2) & 0x3f];
*d++ = basis64[((s[i] & 3) << 4) | (s[i + 1] >> 4)];
*d++ = basis64[((s[i + 1] & 0x0f) << 2) | (s[i + 2] >> 6)];
*d++ = basis64[s[i + 2] & 0x3f];
}
if (i < src->len) {
*d++ = basis64[(s[i] >> 2) & 0x3f];
if (i == src->len - 1) {
*d++ = basis64[(s[i] & 3) << 4];
*d++ = '=';
} else {
*d++ = basis64[((s[i] & 3) << 4) | (s[i + 1] >> 4)];
*d++ = basis64[(s[i + 1] & 0x0f) << 2];
}
*d++ = '=';
}
dst->len = d - dst->data;
*d++ = '\0';
return NGX_OK;
}
ngx_int_t ngx_decode_base64(ngx_pool_t *pool, ngx_str_t *src, ngx_str_t *dst)
{
u_char *d, *s, c;
if (!(d = ngx_palloc(pool, ((src->len + 3) / 4) * 3))) {
return NGX_ABORT;
}
dst->data = d;
s = src->data;
if (*s == '+') {
c = 62;
} else if (*s == '/') {
c = 63;
} else if (*s >= '0' && *s <= '9') {
c = *s - '0' + 52;
} else if (*s >= 'A' && *s <= 'Z') {
c = *s - 'A';
} else if (*s >= 'a' && *s <= 'z') {
c = *s - 'a' + 26;
} else {
return NGX_ERROR;
}
return NGX_OK;
}
#if 0
char *ngx_psprintf(ngx_pool_t *p, const char *fmt, ...)
{

View File

@ -92,6 +92,9 @@ static ngx_int_t ngx_http_access_handler(ngx_http_request_t *r)
rule = alcf->rules->elts;
for (i = 0; i < alcf->rules->nelts; i++) {
ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "%08X %08X %08X",
addr_in->sin_addr.s_addr, rule[i].mask, rule[i].addr);
if ((addr_in->sin_addr.s_addr & rule[i].mask) == rule[i].addr) {
if (rule[i].deny) {
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,

View File

@ -341,6 +341,16 @@ void ngx_http_handler(ngx_http_request_t *r)
break;
}
if (r->keepalive && r->headers_in.msie && r->method == NGX_HTTP_POST) {
/*
* MSIE may wait for some time if the response for the POST request
* is sent over the keepalive connection
*/
r->keepalive = 0;
}
#if 0
/* TEST STUB */ r->http_version = NGX_HTTP_VERSION_10;
/* TEST STUB */ r->keepalive = 0;