View | Details | Raw Unified | Return to bug 50945
Collapse All | Expand All

(-)modules/proxy/mod_proxy_ajp.c (+46 lines)
Lines 191-196 Link Here
191
    apr_size_t maxsize = AJP_MSG_BUFFER_SZ;
191
    apr_size_t maxsize = AJP_MSG_BUFFER_SZ;
192
    int send_body = 0;
192
    int send_body = 0;
193
    apr_off_t content_length = 0;
193
    apr_off_t content_length = 0;
194
    int original_status = r->status;
195
    const char *original_status_line = r->status_line;
194
196
195
    if (psf->io_buffer_size_set)
197
    if (psf->io_buffer_size_set)
196
       maxsize = psf->io_buffer_size;
198
       maxsize = psf->io_buffer_size;
Lines 433-444 Link Here
433
                if (status != APR_SUCCESS) {
435
                if (status != APR_SUCCESS) {
434
                    backend_failed = 1;
436
                    backend_failed = 1;
435
                }
437
                }
438
                else if ((r->status == 401) && psf->error_override) {
439
                    const char *buf;
440
                    const char *wa = "WWW-Authenticate";
441
                    if ((buf = apr_table_get(r->headers_out, wa))) {
442
                        apr_table_set(r->err_headers_out, wa, buf);
443
                    } else {
444
                        ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
445
                                     "ap_proxy_ajp_request: origin server "
446
                                     "sent 401 without WWW-Authenticate header");
447
                    }
448
                }
436
                headers_sent = 1;
449
                headers_sent = 1;
437
                break;
450
                break;
438
            case CMD_AJP13_SEND_BODY_CHUNK:
451
            case CMD_AJP13_SEND_BODY_CHUNK:
439
                /* AJP13_SEND_BODY_CHUNK: piece of data */
452
                /* AJP13_SEND_BODY_CHUNK: piece of data */
440
                status = ajp_parse_data(r, conn->data, &size, &send_body_chunk_buff);
453
                status = ajp_parse_data(r, conn->data, &size, &send_body_chunk_buff);
441
                if (status == APR_SUCCESS) {
454
                if (status == APR_SUCCESS) {
455
                    /* If we are overriding the errors, we can't put the content
456
                     * of the page into the brigade.
457
                     */
458
                    if (!psf->error_override || !ap_is_HTTP_ERROR(r->status)) {
442
                    /* AJP13_SEND_BODY_CHUNK with zero length
459
                    /* AJP13_SEND_BODY_CHUNK with zero length
443
                     * is explicit flush message
460
                     * is explicit flush message
444
                     */
461
                     */
Lines 455-460 Link Here
455
                    else {
472
                    else {
456
                        apr_status_t rv;
473
                        apr_status_t rv;
457
474
475
                            /* Handle the case where the error document is itself reverse
476
                             * proxied and was successful. We must maintain any previous
477
                             * error status so that an underlying error (eg HTTP_NOT_FOUND)
478
                             * doesn't become an HTTP_OK.
479
                             */
480
                            if (psf->error_override && !ap_is_HTTP_ERROR(r->status)
481
                                    && ap_is_HTTP_ERROR(original_status)) {
482
                                r->status = original_status;
483
                                r->status_line = original_status_line;
484
                            }
485
458
                        e = apr_bucket_transient_create(send_body_chunk_buff, size,
486
                        e = apr_bucket_transient_create(send_body_chunk_buff, size,
459
                                                    r->connection->bucket_alloc);
487
                                                    r->connection->bucket_alloc);
460
                        APR_BRIGADE_INSERT_TAIL(output_brigade, e);
488
                        APR_BRIGADE_INSERT_TAIL(output_brigade, e);
Lines 485-490 Link Here
485
                        apr_brigade_cleanup(output_brigade);
513
                        apr_brigade_cleanup(output_brigade);
486
                    }
514
                    }
487
                }
515
                }
516
		}
488
                else {
517
                else {
489
                    backend_failed = 1;
518
                    backend_failed = 1;
490
                }
519
                }
Lines 494-499 Link Here
494
                if (status != APR_SUCCESS) {
523
                if (status != APR_SUCCESS) {
495
                    backend_failed = 1;
524
                    backend_failed = 1;
496
                }
525
                }
526
		/* If we are overriding the errors, we must not send anything to
527
		* the client, especially as the brigade already contains headers.
528
		* So do nothing here, and it will be cleaned up below.
529
		*/
530
		if (!psf->error_override || !ap_is_HTTP_ERROR(r->status)) {
531
497
                e = apr_bucket_eos_create(r->connection->bucket_alloc);
532
                e = apr_bucket_eos_create(r->connection->bucket_alloc);
498
                APR_BRIGADE_INSERT_TAIL(output_brigade, e);
533
                APR_BRIGADE_INSERT_TAIL(output_brigade, e);
499
                if (ap_pass_brigade(r->output_filters,
534
                if (ap_pass_brigade(r->output_filters,
Lines 504-509 Link Here
504
                }
539
                }
505
                /* XXX: what about flush here? See mod_jk */
540
                /* XXX: what about flush here? See mod_jk */
506
                data_sent = 1;
541
                data_sent = 1;
542
		}
507
                request_ended = 1;
543
                request_ended = 1;
508
                break;
544
                break;
509
            default:
545
            default:
Lines 582-589 Link Here
582
                     "proxy: got response from %pI (%s)",
618
                     "proxy: got response from %pI (%s)",
583
                     conn->worker->cp->addr,
619
                     conn->worker->cp->addr,
584
                     conn->worker->hostname);
620
                     conn->worker->hostname);
621
622
        if (psf->error_override && ap_is_HTTP_ERROR(r->status)) {
623
            /* clear r->status for override error, otherwise ErrorDocument
624
             * thinks that this is a recursive error, and doesn't find the
625
             * custom error page
626
             */
627
            rv = r->status;
628
            r->status = HTTP_OK;
629
        } else {
585
        rv = OK;
630
        rv = OK;
586
    }
631
    }
632
    }
587
633
588
    if (backend_failed) {
634
    if (backend_failed) {
589
        ap_log_error(APLOG_MARK, APLOG_ERR, status, r->server,
635
        ap_log_error(APLOG_MARK, APLOG_ERR, status, r->server,

Return to bug 50945