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

Function hc_read_headers

modules/proxy/mod_proxy_hcheck.c:730–792  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

728}
729
730static int hc_read_headers(request_rec *r)
731{
732 char buffer[HUGE_STRING_LEN];
733 int len;
734 const char *ct;
735
736 len = ap_getline(buffer, sizeof(buffer), r, 1);
737 if (len <= 0) {
738 return !OK;
739 }
740 ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, APLOGNO(03254)
741 "%.*s", len, buffer);
742 /* for the below, see ap_proxy_http_process_response() */
743 if (apr_date_checkmask(buffer, "HTTP/#.# ###*")) {
744 int major;
745 char keepchar;
746 int proxy_status = OK;
747 const char *proxy_status_line = NULL;
748
749 major = buffer[5] - '0';
750 if ((major != 1) || (len >= sizeof(buffer)-1)) {
751 return !OK;
752 }
753
754 keepchar = buffer[12];
755 buffer[12] = '\0';
756 proxy_status = atoi(&buffer[9]);
757 if (keepchar != '\0') {
758 buffer[12] = keepchar;
759 } else {
760 buffer[12] = ' ';
761 buffer[13] = '\0';
762 }
763 proxy_status_line = apr_pstrdup(r->pool, &buffer[9]);
764 r->status = proxy_status;
765 r->status_line = proxy_status_line;
766 } else {
767 return !OK;
768 }
769
770 /* OK, 1st line is OK... scarf in the headers */
771 while ((len = ap_getline(buffer, sizeof(buffer), r, 1)) > 0) {
772 char *value, *end;
773 ap_log_error(APLOG_MARK, APLOG_TRACE7, 0, r->server, "%.*s",
774 len, buffer);
775 if (!(value = strchr(buffer, ':'))) {
776 return !OK;
777 }
778 *value = '\0';
779 ++value;
780 while (apr_isspace(*value))
781 ++value; /* Skip to start of value */
782 for (end = &value[strlen(value)-1]; end > value && apr_isspace(*end); --end)
783 *end = '\0';
784 apr_table_add(r->headers_out, buffer, value);
785 }
786
787 /* Set the Content-Type for the request if set */

Callers 1

hc_check_httpFunction · 0.85

Calls 3

ap_getlineFunction · 0.85
ap_set_content_typeFunction · 0.85
ap_log_errorFunction · 0.50

Tested by

no test coverage detected