[MINOR] http: introduce a new synchronisation state : HTTP_MSG_DONE

This state indicates that an HTTP message (request or response) is
complete. This will be used to know when we can re-initialize a
new transaction. Right now we only switch to it after the end of
headers if there is no data. When other analysers are implemented,
we can switch to this state too.

The condition to reuse a connection is when the response finishes
after the request. This will have to be checked when setting the
state.
This commit is contained in:
Willy Tarreau 2009-12-22 16:50:27 +01:00
parent 63c9e5ffa6
commit 0394594b06
2 changed files with 19 additions and 0 deletions

View File

@ -181,6 +181,8 @@
#define HTTP_MSG_DATA_CRLF 31 // skipping CRLF after data chunk #define HTTP_MSG_DATA_CRLF 31 // skipping CRLF after data chunk
#define HTTP_MSG_TRAILERS 32 // trailers (post-data entity headers) #define HTTP_MSG_TRAILERS 32 // trailers (post-data entity headers)
/* we enter this state when we're done with the current message */
#define HTTP_MSG_DONE 33 // message done, waiting to resync for next one.
/* various data sources for the responses */ /* various data sources for the responses */
#define DATA_SRC_NONE 0 #define DATA_SRC_NONE 0

View File

@ -2687,6 +2687,11 @@ int http_process_request(struct session *s, struct buffer *req, int an_bit)
req->analysers |= AN_REQ_HTTP_BODY; req->analysers |= AN_REQ_HTTP_BODY;
} }
/* if we're not expecting anything else, we're done with this request */
if (!(txn->flags & (TX_REQ_TE_CHNK|TX_REQ_CNT_LEN)) &&
(txn->flags & TX_CON_WANT_MSK) != TX_CON_WANT_TUN)
msg->msg_state = HTTP_MSG_DONE;
/************************************************************* /*************************************************************
* OK, that's finished for the headers. We have done what we * * OK, that's finished for the headers. We have done what we *
* could. Let's switch to the DATA state. * * could. Let's switch to the DATA state. *
@ -3563,6 +3568,18 @@ int http_process_res_common(struct session *t, struct buffer *rep, int an_bit, s
must_close = 0; must_close = 0;
} }
/* If we're not expecting anything else, we're done with this request.
* We know there is nothing anymore when we don't have either chunk
* nor content-length in HTTP/1.1, or when we expect an empty body
* (cf RFC2616#4.4).
*/
if (((txn->flags & TX_CON_WANT_MSK) != TX_CON_WANT_TUN) &&
(((txn->flags & (TX_RES_VER_11|TX_RES_TE_CHNK|TX_RES_CNT_LEN)) == TX_RES_VER_11) ||
((txn->flags & TX_RES_CNT_LEN) &&
(txn->meth == HTTP_METH_HEAD ||
!msg->hdr_content_len || txn->status == 204 || txn->status == 304))))
msg->msg_state = HTTP_MSG_DONE;
/************************************************************* /*************************************************************
* OK, that's finished for the headers. We have done what we * * OK, that's finished for the headers. We have done what we *
* could. Let's switch to the DATA state. * * could. Let's switch to the DATA state. *