| 317 | #endif |
| 318 | |
| 319 | static void assign_headers(request_rec *r, const h2_request *req, |
| 320 | int no_body, int is_connect) |
| 321 | { |
| 322 | const char *cl; |
| 323 | |
| 324 | r->headers_in = apr_table_clone(r->pool, req->headers); |
| 325 | |
| 326 | if (req->authority && !is_connect) { |
| 327 | /* for internal handling, we have to simulate that :authority |
| 328 | * came in as Host:, RFC 9113 ch. says that mismatches between |
| 329 | * :authority and Host: SHOULD be rejected as malformed. However, |
| 330 | * we are more lenient and just replace any Host: if we have |
| 331 | * an :authority. |
| 332 | */ |
| 333 | const char *orig_host = apr_table_get(req->headers, "Host"); |
| 334 | if (orig_host && strcmp(req->authority, orig_host)) { |
| 335 | ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(10401) |
| 336 | "overwriting 'Host: %s' with :authority: %s'", |
| 337 | orig_host, req->authority); |
| 338 | apr_table_setn(r->subprocess_env, "H2_ORIGINAL_HOST", orig_host); |
| 339 | } |
| 340 | apr_table_setn(r->headers_in, "Host", req->authority); |
| 341 | ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, |
| 342 | "set 'Host: %s' from :authority", req->authority); |
| 343 | } |
| 344 | |
| 345 | /* Unless we open a byte stream via CONNECT, apply content-length guards. */ |
| 346 | if (!is_connect) { |
| 347 | cl = apr_table_get(req->headers, "Content-Length"); |
| 348 | if (no_body) { |
| 349 | if (!cl && apr_table_get(req->headers, "Content-Type")) { |
| 350 | /* If we have a content-type, but already seen eos, no more |
| 351 | * data will come. Signal a zero content length explicitly. |
| 352 | */ |
| 353 | apr_table_setn(req->headers, "Content-Length", "0"); |
| 354 | } |
| 355 | } |
| 356 | #if !AP_HAS_RESPONSE_BUCKETS |
| 357 | else if (!cl) { |
| 358 | /* there may be a body and we have internal HTTP/1.1 processing. |
| 359 | * If the Content-Length is unspecified, we MUST simulate |
| 360 | * chunked Transfer-Encoding. |
| 361 | * |
| 362 | * HTTP/2 does not need a Content-Length for framing. Ideally |
| 363 | * all clients set the EOS flag on the header frame if they |
| 364 | * do not intent to send a body. However, forwarding proxies |
| 365 | * might just no know at the time and send an empty DATA |
| 366 | * frame with EOS much later. |
| 367 | */ |
| 368 | apr_table_mergen(r->headers_in, "Transfer-Encoding", "chunked"); |
| 369 | } |
| 370 | #endif /* else AP_HAS_RESPONSE_BUCKETS */ |
| 371 | } |
| 372 | } |
| 373 | |
| 374 | request_rec *h2_create_request_rec(const h2_request *req, conn_rec *c, |
| 375 | int no_body) |
no outgoing calls
no test coverage detected