*/
struct http_msg {
enum h1_state msg_state; /* where we are in the current message parsing */
- /* 3 bytes unused here */
+ unsigned char vsn; /* HTTP version, 4 bits per digit */
+ /* 2 bytes unused here */
unsigned int flags; /* flags describing the message (HTTP version, ...) */
struct channel *chn; /* pointer to the channel transporting the message */
};
struct htx *htx;
struct htx_sl *sl;
char http_ver;
- int len;
DBG_TRACE_ENTER(STRM_EV_STRM_ANA|STRM_EV_HTTP_ANA, s, txn, msg);
htx = htxbuf(&req->buf);
sl = http_get_stline(htx);
- len = HTX_SL_REQ_VLEN(sl);
- if (len < 6) {
+ if ((sl->flags & HTX_SL_F_NOT_HTTP) || HTX_SL_REQ_VLEN(sl) != 8) {
+ /* Not an HTTP request */
http_ver = 0;
+ msg->vsn = 0;
}
else {
char *ptr;
ptr = HTX_SL_REQ_VPTR(sl);
+ msg->vsn = ((ptr[5] - '0') << 4) + (ptr[7] - '0');
http_ver = ptr[5] - '0';
}
BUG_ON(htx_get_first_type(htx) != HTX_BLK_RES_SL);
sl = http_get_stline(htx);
+ if ((sl->flags & HTX_SL_F_NOT_HTTP) || HTX_SL_RES_VLEN(sl) != 8) {
+ /* Not an HTTP response */
+ msg->vsn = 0;
+ }
+ else {
+ /* HTTP response from a server, use it to set the response version */
+ char *ptr;
+
+ ptr = HTX_SL_RES_VPTR(sl);
+ msg->vsn = ((ptr[5] - '0') << 4) + (ptr[7] - '0');
+ }
+
/* Adjust server's health based on status code. Note: status codes 501
* and 505 are triggered on demand by client request, so we must not
* count them as server failures.