Lines 188-197
static int ap_proxy_ajp_request(apr_pool
Link Here
|
188 |
proxy_server_conf *psf = |
188 |
proxy_server_conf *psf = |
189 |
ap_get_module_config(r->server->module_config, &proxy_module); |
189 |
ap_get_module_config(r->server->module_config, &proxy_module); |
190 |
apr_size_t maxsize = AJP_MSG_BUFFER_SZ; |
190 |
apr_size_t maxsize = AJP_MSG_BUFFER_SZ; |
191 |
int send_body = 0; |
191 |
int send_body = 0; |
192 |
apr_off_t content_length = 0; |
192 |
apr_off_t content_length = 0; |
|
|
193 |
int original_status = r->status; |
194 |
const char *original_status_line = r->status_line; |
193 |
|
195 |
|
194 |
if (psf->io_buffer_size_set) |
196 |
if (psf->io_buffer_size_set) |
195 |
maxsize = psf->io_buffer_size; |
197 |
maxsize = psf->io_buffer_size; |
196 |
if (maxsize > AJP_MAX_BUFFER_SZ) |
198 |
if (maxsize > AJP_MAX_BUFFER_SZ) |
197 |
maxsize = AJP_MAX_BUFFER_SZ; |
199 |
maxsize = AJP_MAX_BUFFER_SZ; |
Lines 428-443
static int ap_proxy_ajp_request(apr_pool
Link Here
|
428 |
/* AJP13_SEND_HEADERS: process them */ |
430 |
/* AJP13_SEND_HEADERS: process them */ |
429 |
status = ajp_parse_header(r, conf, conn->data); |
431 |
status = ajp_parse_header(r, conf, conn->data); |
430 |
if (status != APR_SUCCESS) { |
432 |
if (status != APR_SUCCESS) { |
431 |
backend_failed = 1; |
433 |
backend_failed = 1; |
432 |
} |
434 |
} |
|
|
435 |
else if ((r->status == 401) && psf->error_override) { |
436 |
const char *buf; |
437 |
const char *wa = "WWW-Authenticate"; |
438 |
if ((buf = apr_table_get(r->headers_out, wa))) { |
439 |
apr_table_set(r->err_headers_out, wa, buf); |
440 |
} else { |
441 |
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, |
442 |
"ap_proxy_ajp_request: origin server " |
443 |
"sent 401 without WWW-Authenticate header"); |
444 |
} |
445 |
} |
433 |
headers_sent = 1; |
446 |
headers_sent = 1; |
434 |
break; |
447 |
break; |
435 |
case CMD_AJP13_SEND_BODY_CHUNK: |
448 |
case CMD_AJP13_SEND_BODY_CHUNK: |
436 |
/* AJP13_SEND_BODY_CHUNK: piece of data */ |
449 |
/* AJP13_SEND_BODY_CHUNK: piece of data */ |
437 |
status = ajp_parse_data(r, conn->data, &size, &send_body_chunk_buff); |
450 |
status = ajp_parse_data(r, conn->data, &size, &send_body_chunk_buff); |
438 |
if (status == APR_SUCCESS) { |
451 |
if (status == APR_SUCCESS) { |
|
|
452 |
/* If we are overriding the errors, we can't put the content |
453 |
* of the page into the brigade. |
454 |
*/ |
455 |
if (!psf->error_override || !ap_is_HTTP_ERROR(r->status)) { |
439 |
/* AJP13_SEND_BODY_CHUNK with zero length |
456 |
/* AJP13_SEND_BODY_CHUNK with zero length |
440 |
* is explicit flush message |
457 |
* is explicit flush message |
441 |
*/ |
458 |
*/ |
442 |
if (size == 0) { |
459 |
if (size == 0) { |
443 |
if (headers_sent) { |
460 |
if (headers_sent) { |
Lines 450-459
static int ap_proxy_ajp_request(apr_pool
Link Here
|
450 |
} |
467 |
} |
451 |
} |
468 |
} |
452 |
else { |
469 |
else { |
453 |
apr_status_t rv; |
470 |
apr_status_t rv; |
454 |
|
471 |
|
|
|
472 |
/* Handle the case where the error document is itself reverse |
473 |
* proxied and was successful. We must maintain any previous |
474 |
* error status so that an underlying error (eg HTTP_NOT_FOUND) |
475 |
* doesn't become an HTTP_OK. |
476 |
*/ |
477 |
if (psf->error_override && !ap_is_HTTP_ERROR(r->status) |
478 |
&& ap_is_HTTP_ERROR(original_status)) { |
479 |
r->status = original_status; |
480 |
r->status_line = original_status_line; |
481 |
} |
482 |
|
455 |
e = apr_bucket_transient_create(send_body_chunk_buff, size, |
483 |
e = apr_bucket_transient_create(send_body_chunk_buff, size, |
456 |
r->connection->bucket_alloc); |
484 |
r->connection->bucket_alloc); |
457 |
APR_BRIGADE_INSERT_TAIL(output_brigade, e); |
485 |
APR_BRIGADE_INSERT_TAIL(output_brigade, e); |
458 |
|
486 |
|
459 |
if ((conn->worker->flush_packets == flush_on) || |
487 |
if ((conn->worker->flush_packets == flush_on) || |
Lines 478-502
static int ap_proxy_ajp_request(apr_pool
Link Here
|
478 |
output_failed = 1; |
506 |
output_failed = 1; |
479 |
} |
507 |
} |
480 |
data_sent = 1; |
508 |
data_sent = 1; |
481 |
apr_brigade_cleanup(output_brigade); |
509 |
apr_brigade_cleanup(output_brigade); |
482 |
} |
510 |
} |
|
|
511 |
} |
483 |
else { |
512 |
else { |
484 |
backend_failed = 1; |
513 |
backend_failed = 1; |
485 |
} |
514 |
} |
486 |
break; |
515 |
break; |
487 |
case CMD_AJP13_END_RESPONSE: |
516 |
case CMD_AJP13_END_RESPONSE: |
|
|
517 |
/* If we are overriding the errors, we must not send anything to |
518 |
* the client, especially as the brigade already contains headers. |
519 |
* So do nothing here, and it will be cleaned up below. |
520 |
*/ |
521 |
if (!psf->error_override || !ap_is_HTTP_ERROR(r->status)) { |
488 |
e = apr_bucket_eos_create(r->connection->bucket_alloc); |
522 |
e = apr_bucket_eos_create(r->connection->bucket_alloc); |
489 |
APR_BRIGADE_INSERT_TAIL(output_brigade, e); |
523 |
APR_BRIGADE_INSERT_TAIL(output_brigade, e); |
490 |
if (ap_pass_brigade(r->output_filters, |
524 |
if (ap_pass_brigade(r->output_filters, |
491 |
output_brigade) != APR_SUCCESS) { |
525 |
output_brigade) != APR_SUCCESS) { |
492 |
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, |
526 |
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, |
493 |
"proxy: error processing end"); |
527 |
"proxy: error processing end"); |
494 |
output_failed = 1; |
528 |
output_failed = 1; |
495 |
} |
529 |
} |
496 |
/* XXX: what about flush here? See mod_jk */ |
530 |
/* XXX: what about flush here? See mod_jk */ |
497 |
data_sent = 1; |
531 |
data_sent = 1; |
|
|
532 |
} |
498 |
request_ended = 1; |
533 |
request_ended = 1; |
499 |
break; |
534 |
break; |
500 |
default: |
535 |
default: |
501 |
backend_failed = 1; |
536 |
backend_failed = 1; |
502 |
break; |
537 |
break; |
Lines 567-578
static int ap_proxy_ajp_request(apr_pool
Link Here
|
567 |
else { |
602 |
else { |
568 |
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, |
603 |
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, |
569 |
"proxy: got response from %pI (%s)", |
604 |
"proxy: got response from %pI (%s)", |
570 |
conn->worker->cp->addr, |
605 |
conn->worker->cp->addr, |
571 |
conn->worker->hostname); |
606 |
conn->worker->hostname); |
|
|
607 |
|
608 |
if (psf->error_override && ap_is_HTTP_ERROR(r->status)) { |
609 |
/* clear r->status for override error, otherwise ErrorDocument |
610 |
* thinks that this is a recursive error, and doesn't find the |
611 |
* custom error page |
612 |
*/ |
613 |
rv = r->status; |
614 |
r->status = HTTP_OK; |
615 |
} else { |
572 |
rv = OK; |
616 |
rv = OK; |
573 |
} |
617 |
} |
|
|
618 |
} |
574 |
|
619 |
|
575 |
if (backend_failed) { |
620 |
if (backend_failed) { |
576 |
ap_log_error(APLOG_MARK, APLOG_ERR, status, r->server, |
621 |
ap_log_error(APLOG_MARK, APLOG_ERR, status, r->server, |
577 |
"proxy: dialog to %pI (%s) failed", |
622 |
"proxy: dialog to %pI (%s) failed", |
578 |
conn->worker->cp->addr, |
623 |
conn->worker->cp->addr, |