| 6368 | } |
| 6369 | |
| 6370 | bool |
| 6371 | HttpTransact::is_request_valid(State *s, HTTPHdr *incoming_request) |
| 6372 | { |
| 6373 | RequestError_t incoming_error; |
| 6374 | URL *url = nullptr; |
| 6375 | |
| 6376 | // If we are blind tunneling the header is just a synthesized placeholder anyway. |
| 6377 | // But we do have to check that we are not tunneling to a dynamic port that is |
| 6378 | // not in the connect_ports list. |
| 6379 | if (s->client_info.port_attribute == HttpProxyPort::TRANSPORT_BLIND_TUNNEL) { |
| 6380 | if (s->tunnel_port_is_dynamic && |
| 6381 | !is_port_in_range(incoming_request->url_get()->port_get(), s->http_config_param->connect_ports)) { |
| 6382 | TxnDbg(dbg_ctl_http_trans, "Rejected a tunnel to port %d not in connect_ports", incoming_request->url_get()->port_get()); |
| 6383 | return false; |
| 6384 | } |
| 6385 | return true; |
| 6386 | } |
| 6387 | |
| 6388 | if (incoming_request) { |
| 6389 | url = incoming_request->url_get(); |
| 6390 | } |
| 6391 | |
| 6392 | incoming_error = check_request_validity(s, incoming_request); |
| 6393 | switch (incoming_error) { |
| 6394 | case NO_REQUEST_HEADER_ERROR: |
| 6395 | TxnDbg(dbg_ctl_http_trans, "no request header errors"); |
| 6396 | break; |
| 6397 | case FAILED_PROXY_AUTHORIZATION: |
| 6398 | TxnDbg(dbg_ctl_http_trans, "failed proxy authorization"); |
| 6399 | SET_VIA_STRING(VIA_DETAIL_TUNNEL, VIA_DETAIL_TUNNEL_NO_FORWARD); |
| 6400 | build_error_response(s, HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED, "Proxy Authentication Required", |
| 6401 | "access#proxy_auth_required"); |
| 6402 | return false; |
| 6403 | case NON_EXISTANT_REQUEST_HEADER: |
| 6404 | /* fall through */ |
| 6405 | case BAD_HTTP_HEADER_SYNTAX: { |
| 6406 | TxnDbg(dbg_ctl_http_trans, "non-existent/bad header"); |
| 6407 | SET_VIA_STRING(VIA_DETAIL_TUNNEL, VIA_DETAIL_TUNNEL_NO_FORWARD); |
| 6408 | build_error_response(s, HTTP_STATUS_BAD_REQUEST, "Invalid HTTP Request", "request#syntax_error"); |
| 6409 | return false; |
| 6410 | } |
| 6411 | |
| 6412 | case MISSING_HOST_FIELD: |
| 6413 | |
| 6414 | //////////////////////////////////////////////////////////////////// |
| 6415 | // FIX: are we sure the following logic is right? it seems that // |
| 6416 | // we shouldn't complain about the missing host header until // |
| 6417 | // we know we really need one --- are we sure we need a host // |
| 6418 | // header at this point? // |
| 6419 | // // |
| 6420 | // FIX: also, let's clean up the transparency code to remove the // |
| 6421 | // SunOS conditionals --- we will be transparent on all // |
| 6422 | // platforms soon! in fact, I really want a method that i // |
| 6423 | // can call for each transaction to say if the transaction // |
| 6424 | // is a forward proxy request, a transparent request, a // |
| 6425 | // reverse proxy request, etc --- the detail of how we // |
| 6426 | // determine the cases should be hidden behind the method. // |
| 6427 | //////////////////////////////////////////////////////////////////// |
no test coverage detected