MCPcopy Create free account
hub / github.com/apache/httpd / ajp_unmarshal_response

Function ajp_unmarshal_response

modules/proxy/ajp_header.c:540–683  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

538}
539
540static apr_status_t ajp_unmarshal_response(ajp_msg_t *msg,
541 request_rec *r,
542 proxy_dir_conf *dconf)
543{
544 apr_uint16_t status;
545 apr_status_t rc;
546 const char *ptr;
547 apr_uint16_t num_headers;
548 int i;
549
550 rc = ajp_msg_get_uint16(msg, &status);
551
552 if (rc != APR_SUCCESS) {
553 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00983)
554 "ajp_unmarshal_response: Null status");
555 return rc;
556 }
557 r->status = status;
558
559 rc = ajp_msg_get_string(msg, &ptr);
560 if (rc == APR_SUCCESS) {
561#if APR_CHARSET_EBCDIC /* copy only if we have to */
562 ptr = apr_pstrdup(r->pool, ptr);
563 ap_xlate_proto_from_ascii(ptr, strlen(ptr));
564#endif
565 r->status_line = apr_psprintf(r->pool, "%d %s", status, ptr);
566 }
567 else {
568 r->status_line = NULL;
569 }
570
571 ap_log_rerror(APLOG_MARK, APLOG_TRACE4, 0, r,
572 "ajp_unmarshal_response: status = %d", status);
573
574 rc = ajp_msg_get_uint16(msg, &num_headers);
575 if (rc == APR_SUCCESS) {
576 apr_table_t *save_table;
577
578 /* First, tuck away all already existing cookies */
579 /*
580 * Could optimize here, but just in case we want to
581 * also save other headers, keep this logic.
582 */
583 save_table = apr_table_make(r->pool, num_headers + 2);
584 apr_table_do(addit_dammit, save_table, r->headers_out,
585 "Set-Cookie", NULL);
586 r->headers_out = save_table;
587 }
588 else {
589 /*
590 * Reset headers, but not to NULL because things below the chain expect
591 * this to be non NULL e.g. the ap_content_length_filter.
592 */
593 r->headers_out = apr_table_make(r->pool, 1);
594 num_headers = 0;
595 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(10405)
596 "ajp_unmarshal_response: Bad number of headers");
597 return rc;

Callers 1

ajp_parse_headerFunction · 0.85

Calls 9

ajp_msg_get_uint16Function · 0.85
ajp_msg_get_stringFunction · 0.85
ajp_msg_peek_uint16Function · 0.85
long_res_header_for_scFunction · 0.85
ap_cstr_casecmpFunction · 0.85
ap_set_content_typeFunction · 0.85

Tested by

no test coverage detected