Module: kamailio
Branch: master
Commit: dae0d454f6ae5a4b705db325cca5f905cbf1a870
URL: 
https://github.com/kamailio/kamailio/commit/dae0d454f6ae5a4b705db325cca5f905cbf1a870

Author: Daniel-Constantin Mierla <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date: 2026-03-05T17:35:23+01:00

core: tcp - add rmode to tcp read headers

---

Modified: src/core/tcp_read.c
Modified: src/core/tcp_read.h

---

Diff:  
https://github.com/kamailio/kamailio/commit/dae0d454f6ae5a4b705db325cca5f905cbf1a870.diff
Patch: 
https://github.com/kamailio/kamailio/commit/dae0d454f6ae5a4b705db325cca5f905cbf1a870.patch

---

diff --git a/src/core/tcp_read.c b/src/core/tcp_read.c
index 3a995936093..f3fee0c254a 100644
--- a/src/core/tcp_read.c
+++ b/src/core/tcp_read.c
@@ -445,7 +445,8 @@ int tcp_read(struct tcp_connection *c, rd_conn_flags_t 
*flags)
  * when either r->body!=0 or r->state==H_BODY =>
  * all headers have been read. It should be called in a while loop.
  * returns < 0 if error or 0 if EOF */
-int tcp_read_headers(struct tcp_connection *c, rd_conn_flags_t *read_flags)
+int tcp_read_headers(
+               struct tcp_connection *c, rd_conn_flags_t *read_flags, int 
rmode)
 {
        int bytes, remaining;
        char *p;
@@ -605,7 +606,8 @@ int tcp_read_headers(struct tcp_connection *c, 
rd_conn_flags_t *read_flags)
                                                /* found LF LF */
                                                r->state = H_BODY;
 #ifdef READ_HTTP11
-                                               if(cfg_get(tcp, tcp_cfg, 
accept_no_cl) != 0)
+                                               if(rmode != 0
+                                                               || cfg_get(tcp, 
tcp_cfg, accept_no_cl) != 0)
                                                        tcp_http11_continue(c);
 #endif
                                                if(TCP_REQ_HAS_CLEN(r)) {
@@ -617,7 +619,9 @@ int tcp_read_headers(struct tcp_connection *c, 
rd_conn_flags_t *read_flags)
                                                                goto skip;
                                                        }
                                                } else {
-                                                       if(cfg_get(tcp, 
tcp_cfg, accept_no_cl) != 0) {
+                                                       if(rmode != 0
+                                                                       || 
cfg_get(tcp, tcp_cfg, accept_no_cl)
+                                                                               
           != 0) {
 #ifdef READ_MSRP
                                                                /* if MSRP 
message */
                                                                if(c->req.flags 
& F_TCP_REQ_MSRP_FRAME) {
@@ -678,7 +682,7 @@ int tcp_read_headers(struct tcp_connection *c, 
rd_conn_flags_t *read_flags)
                                        /* found LF CR LF */
                                        r->state = H_BODY;
 #ifdef READ_HTTP11
-                                       if(cfg_get(tcp, tcp_cfg, accept_no_cl) 
!= 0)
+                                       if(rmode != 0 || cfg_get(tcp, tcp_cfg, 
accept_no_cl) != 0)
                                                tcp_http11_continue(c);
 #endif
                                        if(TCP_REQ_HAS_CLEN(r)) {
@@ -690,7 +694,8 @@ int tcp_read_headers(struct tcp_connection *c, 
rd_conn_flags_t *read_flags)
                                                        goto skip;
                                                }
                                        } else {
-                                               if(cfg_get(tcp, tcp_cfg, 
accept_no_cl) != 0) {
+                                               if(rmode != 0
+                                                               || cfg_get(tcp, 
tcp_cfg, accept_no_cl) != 0) {
 #ifdef READ_MSRP
                                                        /* if MSRP message */
                                                        if(c->req.flags & 
F_TCP_REQ_MSRP_FRAME) {
@@ -744,7 +749,7 @@ int tcp_read_headers(struct tcp_connection *c, 
rd_conn_flags_t *read_flags)
                                        case '\n':
                                                break;
                                        case '\r':
-                                               if(cfg_get(tcp, tcp_cfg, 
crlf_ping)) {
+                                               if(rmode != 0 || cfg_get(tcp, 
tcp_cfg, crlf_ping)) {
                                                        r->state = 
H_SKIP_EMPTY_CR_FOUND;
                                                        r->start = p;
                                                }
@@ -1634,11 +1639,11 @@ int tcp_read_req(struct tcp_connection *con, int 
*bytes_read,
                                if(bytes >= 0) {
                                        if(!(con->req.flags & F_TCP_REQ_HEP3)) {
                                                /* not hep3, try to read 
headers */
-                                               bytes = tcp_read_headers(con, 
read_flags);
+                                               bytes = tcp_read_headers(con, 
read_flags, 0);
                                        }
                                }
                        } else {
-                               bytes = tcp_read_headers(con, read_flags);
+                               bytes = tcp_read_headers(con, read_flags, 0);
                        }
 #ifdef READ_WS
                }
diff --git a/src/core/tcp_read.h b/src/core/tcp_read.h
index 22d5facaeb6..6a4430a0229 100644
--- a/src/core/tcp_read.h
+++ b/src/core/tcp_read.h
@@ -34,7 +34,8 @@ typedef enum rd_conn_flags
        RD_CONN_FORCE_EOF = (1 << 16),
 } rd_conn_flags_t;
 
-int tcp_read_headers(struct tcp_connection *c, rd_conn_flags_t *read_flags);
+int tcp_read_headers(
+               struct tcp_connection *c, rd_conn_flags_t *read_flags, int 
rmode);
 
 int tcp_read_data(int fd, struct tcp_connection *c, char *buf, int b_size,
                rd_conn_flags_t *flags);

_______________________________________________
Kamailio - Development Mailing List -- [email protected]
To unsubscribe send an email to [email protected]
Important: keep the mailing list in the recipients, do not reply only to the 
sender!

Reply via email to