MEDIUM: http: add a pointer to the buffer in http_msg
ACLs and patterns only rely on a struct http_msg and don't know the pointer
to the actual data. struct http_msg will soon only hold relative references
so that's not possible. We need http_msg to hold a reference to the struct
buffer before having relative pointers everywhere.
It is likely that doing so will also result in opportunities to simplify
a number of functions arguments. The following functions are already
candidate :
http_buffer_heavy_realign
http_capture_bad_message
http_change_connection_header
http_forward_trailers
http_header_add_tail
http_header_add_tail2
http_msg_analyzer
http_parse_chunk_size
http_parse_connection_header
http_remove_header2
http_send_name_header
http_skip_chunk_crlf
http_upgrade_v09_to_v10
diff --git a/src/session.c b/src/session.c
index 86aa28c..ac8a8cc 100644
--- a/src/session.c
+++ b/src/session.c
@@ -217,22 +217,6 @@
if (unlikely(fcntl(cfd, F_SETFL, O_NONBLOCK) == -1))
goto out_free_task;
- txn = &s->txn;
- /* Those variables will be checked and freed if non-NULL in
- * session.c:session_free(). It is important that they are
- * properly initialized.
- */
- txn->sessid = NULL;
- txn->srv_cookie = NULL;
- txn->cli_cookie = NULL;
- txn->uri = NULL;
- txn->req.cap = NULL;
- txn->rsp.cap = NULL;
- txn->hdr_idx.v = NULL;
- txn->hdr_idx.size = txn->hdr_idx.used = 0;
- txn->req.flags = 0;
- txn->rsp.flags = 0;
-
if (unlikely((s->req = pool_alloc2(pool2_buffer)) == NULL))
goto out_free_task; /* no memory */
@@ -275,6 +259,25 @@
s->rep->wex = TICK_ETERNITY;
s->rep->analyse_exp = TICK_ETERNITY;
+ txn = &s->txn;
+ /* Those variables will be checked and freed if non-NULL in
+ * session.c:session_free(). It is important that they are
+ * properly initialized.
+ */
+ txn->sessid = NULL;
+ txn->srv_cookie = NULL;
+ txn->cli_cookie = NULL;
+ txn->uri = NULL;
+ txn->req.cap = NULL;
+ txn->rsp.cap = NULL;
+ txn->hdr_idx.v = NULL;
+ txn->hdr_idx.size = txn->hdr_idx.used = 0;
+ txn->req.flags = 0;
+ txn->rsp.flags = 0;
+ /* the HTTP messages need to know what buffer they're associated with */
+ txn->req.buf = s->req;
+ txn->rsp.buf = s->rep;
+
/* finish initialization of the accepted file descriptor */
fd_insert(cfd);
fdtab[cfd].owner = &s->si[0];