| 1512 | } |
| 1513 | |
| 1514 | void |
| 1515 | HttpTransact::HandleRequest(State *s) |
| 1516 | { |
| 1517 | TxnDbg(dbg_ctl_http_trans, "START HttpTransact::HandleRequest"); |
| 1518 | |
| 1519 | if (!s->state_machine->is_waiting_for_full_body && !s->state_machine->is_buffering_request_body) { |
| 1520 | ink_assert(!s->hdr_info.server_request.valid()); |
| 1521 | |
| 1522 | Metrics::Counter::increment(http_rsb.incoming_requests); |
| 1523 | |
| 1524 | if (s->client_info.port_attribute == HttpProxyPort::TRANSPORT_SSL) { |
| 1525 | Metrics::Counter::increment(http_rsb.https_incoming_requests); |
| 1526 | } |
| 1527 | |
| 1528 | /////////////////////////////////////////////// |
| 1529 | // if request is bad, return error response // |
| 1530 | /////////////////////////////////////////////// |
| 1531 | |
| 1532 | if (!(is_request_valid(s, &s->hdr_info.client_request))) { |
| 1533 | Metrics::Counter::increment(http_rsb.invalid_client_requests); |
| 1534 | TxnDbg(dbg_ctl_http_seq, "request invalid."); |
| 1535 | s->next_action = SM_ACTION_SEND_ERROR_CACHE_NOOP; |
| 1536 | // s->next_action = HttpTransact::PROXY_INTERNAL_CACHE_NOOP; |
| 1537 | return; |
| 1538 | } |
| 1539 | TxnDbg(dbg_ctl_http_seq, "request valid."); |
| 1540 | |
| 1541 | if (dbg_ctl_http_chdr_describe.on()) { |
| 1542 | obj_describe(s->hdr_info.client_request.m_http, true); |
| 1543 | } |
| 1544 | // at this point we are guaranteed that the request is good and acceptable. |
| 1545 | // initialize some state variables from the request (client version, |
| 1546 | // client keep-alive, cache action, etc. |
| 1547 | initialize_state_variables_from_request(s, &s->hdr_info.client_request); |
| 1548 | // The following chunk of code will limit the maximum number of websocket connections (TS-3659) |
| 1549 | if (s->is_upgrade_request && s->is_websocket && s->http_config_param->max_websocket_connections >= 0) { |
| 1550 | if (Metrics::Gauge::load(http_rsb.websocket_current_active_client_connections) >= |
| 1551 | s->http_config_param->max_websocket_connections) { |
| 1552 | s->is_websocket = false; // unset to avoid screwing up stats. |
| 1553 | TxnDbg(dbg_ctl_http_trans, "Rejecting websocket connection because the limit has been exceeded"); |
| 1554 | bootstrap_state_variables_from_request(s, &s->hdr_info.client_request); |
| 1555 | build_error_response(s, HTTP_STATUS_SERVICE_UNAVAILABLE, "WebSocket Connection Limit Exceeded", nullptr); |
| 1556 | TRANSACT_RETURN(SM_ACTION_SEND_ERROR_CACHE_NOOP, nullptr); |
| 1557 | } |
| 1558 | } |
| 1559 | |
| 1560 | // The following code is configurable to allow a user to control the max post size (TS-3631) |
| 1561 | if (s->http_config_param->max_post_size > 0 && s->hdr_info.request_content_length > 0 && |
| 1562 | s->hdr_info.request_content_length > s->http_config_param->max_post_size) { |
| 1563 | TxnDbg(dbg_ctl_http_trans, "Max post size %" PRId64 " Client tried to post a body that was too large.", |
| 1564 | s->http_config_param->max_post_size); |
| 1565 | Metrics::Counter::increment(http_rsb.post_body_too_large); |
| 1566 | bootstrap_state_variables_from_request(s, &s->hdr_info.client_request); |
| 1567 | build_error_response(s, HTTP_STATUS_REQUEST_ENTITY_TOO_LARGE, "Request Entity Too Large", "request#entity_too_large"); |
| 1568 | s->squid_codes.log_code = SQUID_LOG_ERR_POST_ENTITY_TOO_LARGE; |
| 1569 | TRANSACT_RETURN(SM_ACTION_SEND_ERROR_CACHE_NOOP, nullptr); |
| 1570 | } |
| 1571 |
nothing calls this directly
no test coverage detected