-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http server: add "HTTP_SRV_REQ_P_F_HOST_ANY_PORT" flag to "Request pr…
…ocessing flags" to allow match host even if port number not eququal
- Loading branch information
Showing
3 changed files
with
10 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/*- | ||
* Copyright (c) 2011 - 2018 Rozhuk Ivan <[email protected]> | ||
* Copyright (c) 2011-2025 Rozhuk Ivan <[email protected]> | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
|
@@ -141,6 +141,7 @@ typedef struct http_srv_settings_s { /* Settings */ | |
/* Request processing flags. */ | ||
#define HTTP_SRV_REQ_P_F_CONNECTION (((uint32_t)1) << 0) /* process 'connection' header value. */ | ||
#define HTTP_SRV_REQ_P_F_HOST (((uint32_t)1) << 1) /* process 'host' header value. */ | ||
#define HTTP_SRV_REQ_P_F_HOST_ANY_PORT (((uint32_t)1) << 2) /* process 'host' header value, ignore port match. */ | ||
/* Responce processing flags. */ | ||
#define HTTP_SRV_RESP_P_F_CONN_CLOSE (((uint32_t)1) << 0) /* force 'Connection: close', use single IO_BUF for send and recv. */ | ||
#define HTTP_SRV_RESP_P_F_SERVER (((uint32_t)1) << 1) /* add 'Server' in answer. */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
|
||
Light Code Base | ||
|
||
Rozhuk Ivan <[email protected]> 2011-2024 | ||
Rozhuk Ivan <[email protected]> 2011-2025 | ||
|
||
Statically linked code library. | ||
Compile and include only things that you need. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/*- | ||
* Copyright (c) 2011-2024 Rozhuk Ivan <[email protected]> | ||
* Copyright (c) 2011-2025 Rozhuk Ivan <[email protected]> | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
|
@@ -1324,7 +1324,8 @@ http_srv_recv_done_cb(tp_task_p tptask, int error, io_buf_p buf, | |
if (0 == host_port) { /* Def http port. */ | ||
host_port = HTTP_PORT; | ||
} | ||
if (sa_port_get(&bnd->s.addr) == host_port && | ||
if ((0 != (HTTP_SRV_REQ_P_F_HOST_ANY_PORT & srv->s.req_p_flags) || | ||
sa_port_get(&bnd->s.addr) == host_port) && | ||
(0 == hostname_list_check_any(&bnd->hst_name_lst) || | ||
0 == hostname_list_check_any(&srv->hst_name_lst))) { | ||
cli->req.flags |= HTTP_SRV_RD_F_HOST_IS_LOCAL; | ||
|
@@ -1333,7 +1334,8 @@ http_srv_recv_done_cb(tp_task_p tptask, int error, io_buf_p buf, | |
arg = NULL; /* Addr info cache. */ | ||
for (i = 0; i < srv->bind_count; i ++) { | ||
if (srv->bnd[i]->s.addr.ss_family != addr.ss_family || | ||
sa_port_get(&srv->bnd[i]->s.addr) != host_port) /* not equal port! */ | ||
(0 == (HTTP_SRV_REQ_P_F_HOST_ANY_PORT & srv->s.req_p_flags) && | ||
sa_port_get(&srv->bnd[i]->s.addr) != host_port)) /* not equal port! */ | ||
continue; | ||
if (0 == sa_addr_is_specified(&srv->bnd[i]->s.addr)) { | ||
/* Binded to: 0.0.0.0 or [::]. */ | ||
|
@@ -1368,7 +1370,8 @@ http_srv_recv_done_cb(tp_task_p tptask, int error, io_buf_p buf, | |
0 == sa_addr_is_loopback(&cli->addr)) /* from ext host? */ | ||
goto conn_from_net_to_loopback; | ||
/* Is hostname point to this host? */ | ||
if (sa_port_get(&bnd->s.addr) == host_port && | ||
if ((0 != (HTTP_SRV_REQ_P_F_HOST_ANY_PORT & srv->s.req_p_flags) || | ||
sa_port_get(&bnd->s.addr) == host_port) && | ||
(0 != action || | ||
0 == hostname_list_check(&bnd->hst_name_lst, cli->req.host, tm) || | ||
0 == hostname_list_check(&srv->hst_name_lst, cli->req.host, tm))) { | ||
|