comparison src/http/modules/ngx_http_proxy_module.c @ 1699:976db8c6fb64

return NGX_ERROR instead of NGX_HTTP_INTERNAL_SERVER_ERROR in u->parse_header()
author Igor Sysoev <igor@sysoev.ru>
date Sun, 09 Dec 2007 08:22:35 +0000
parents bd85a95d60c6
children 40d004d95d88
comparison
equal deleted inserted replaced
1698:70202cd85645 1699:976db8c6fb64
957 ngx_http_proxy_ctx_t *ctx; 957 ngx_http_proxy_ctx_t *ctx;
958 958
959 ctx = ngx_http_get_module_ctx(r, ngx_http_proxy_module); 959 ctx = ngx_http_get_module_ctx(r, ngx_http_proxy_module);
960 960
961 if (ctx == NULL) { 961 if (ctx == NULL) {
962 return NGX_HTTP_INTERNAL_SERVER_ERROR; 962 return NGX_ERROR;
963 } 963 }
964 964
965 rc = ngx_http_proxy_parse_status_line(r, ctx); 965 rc = ngx_http_proxy_parse_status_line(r, ctx);
966 966
967 if (rc == NGX_AGAIN) { 967 if (rc == NGX_AGAIN) {
992 992
993 u->headers_in.status_line.len = ctx->status_end - ctx->status_start; 993 u->headers_in.status_line.len = ctx->status_end - ctx->status_start;
994 u->headers_in.status_line.data = ngx_palloc(r->pool, 994 u->headers_in.status_line.data = ngx_palloc(r->pool,
995 u->headers_in.status_line.len); 995 u->headers_in.status_line.len);
996 if (u->headers_in.status_line.data == NULL) { 996 if (u->headers_in.status_line.data == NULL) {
997 return NGX_HTTP_INTERNAL_SERVER_ERROR; 997 return NGX_ERROR;
998 } 998 }
999 999
1000 ngx_memcpy(u->headers_in.status_line.data, ctx->status_start, 1000 ngx_memcpy(u->headers_in.status_line.data, ctx->status_start,
1001 u->headers_in.status_line.len); 1001 u->headers_in.status_line.len);
1002 1002
1237 1237
1238 /* a header line has been parsed successfully */ 1238 /* a header line has been parsed successfully */
1239 1239
1240 h = ngx_list_push(&r->upstream->headers_in.headers); 1240 h = ngx_list_push(&r->upstream->headers_in.headers);
1241 if (h == NULL) { 1241 if (h == NULL) {
1242 return NGX_HTTP_INTERNAL_SERVER_ERROR; 1242 return NGX_ERROR;
1243 } 1243 }
1244 1244
1245 h->hash = r->header_hash; 1245 h->hash = r->header_hash;
1246 1246
1247 h->key.len = r->header_name_end - r->header_name_start; 1247 h->key.len = r->header_name_end - r->header_name_start;
1248 h->value.len = r->header_end - r->header_start; 1248 h->value.len = r->header_end - r->header_start;
1249 1249
1250 h->key.data = ngx_palloc(r->pool, 1250 h->key.data = ngx_palloc(r->pool,
1251 h->key.len + 1 + h->value.len + 1 + h->key.len); 1251 h->key.len + 1 + h->value.len + 1 + h->key.len);
1252 if (h->key.data == NULL) { 1252 if (h->key.data == NULL) {
1253 return NGX_HTTP_INTERNAL_SERVER_ERROR; 1253 return NGX_ERROR;
1254 } 1254 }
1255 1255
1256 h->value.data = h->key.data + h->key.len + 1; 1256 h->value.data = h->key.data + h->key.len + 1;
1257 h->lowcase_key = h->key.data + h->key.len + 1 + h->value.len + 1; 1257 h->lowcase_key = h->key.data + h->key.len + 1 + h->value.len + 1;
1258 1258
1270 1270
1271 hh = ngx_hash_find(&umcf->headers_in_hash, h->hash, 1271 hh = ngx_hash_find(&umcf->headers_in_hash, h->hash,
1272 h->lowcase_key, h->key.len); 1272 h->lowcase_key, h->key.len);
1273 1273
1274 if (hh && hh->handler(r, h, hh->offset) != NGX_OK) { 1274 if (hh && hh->handler(r, h, hh->offset) != NGX_OK) {
1275 return NGX_HTTP_INTERNAL_SERVER_ERROR; 1275 return NGX_ERROR;
1276 } 1276 }
1277 1277
1278 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 1278 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
1279 "http proxy header: \"%V: %V\"", 1279 "http proxy header: \"%V: %V\"",
1280 &h->key, &h->value); 1280 &h->key, &h->value);
1295 */ 1295 */
1296 1296
1297 if (r->upstream->headers_in.server == NULL) { 1297 if (r->upstream->headers_in.server == NULL) {
1298 h = ngx_list_push(&r->upstream->headers_in.headers); 1298 h = ngx_list_push(&r->upstream->headers_in.headers);
1299 if (h == NULL) { 1299 if (h == NULL) {
1300 return NGX_HTTP_INTERNAL_SERVER_ERROR; 1300 return NGX_ERROR;
1301 } 1301 }
1302 1302
1303 h->hash = ngx_hash(ngx_hash(ngx_hash(ngx_hash( 1303 h->hash = ngx_hash(ngx_hash(ngx_hash(ngx_hash(
1304 ngx_hash('s', 'e'), 'r'), 'v'), 'e'), 'r'); 1304 ngx_hash('s', 'e'), 'r'), 'v'), 'e'), 'r');
1305 1305
1311 } 1311 }
1312 1312
1313 if (r->upstream->headers_in.date == NULL) { 1313 if (r->upstream->headers_in.date == NULL) {
1314 h = ngx_list_push(&r->upstream->headers_in.headers); 1314 h = ngx_list_push(&r->upstream->headers_in.headers);
1315 if (h == NULL) { 1315 if (h == NULL) {
1316 return NGX_HTTP_INTERNAL_SERVER_ERROR; 1316 return NGX_ERROR;
1317 } 1317 }
1318 1318
1319 h->hash = ngx_hash(ngx_hash(ngx_hash('d', 'a'), 't'), 'e'); 1319 h->hash = ngx_hash(ngx_hash(ngx_hash('d', 'a'), 't'), 'e');
1320 1320
1321 h->key.len = sizeof("Date") - 1; 1321 h->key.len = sizeof("Date") - 1;