MINOR: http: compute response time before processing headers

At the moment, HTTP response time is computed after response headers are
processed. This can misleadingly assign to the server some heavy local
processing (eg: regex), and also prevents response headers from passing
information related to the response time (which can sometimes be useful
for stats).

Let's retrieve the reponse time before processing the headers instead.

Note that in order to remain compatible with what was previously done,
we disable the response time when we get a 502 or any bad response. This
should probably be changed in 1.6 since it does not make sense anymore
to lose this information.
This commit is contained in:
Willy Tarreau 2013-09-23 16:44:27 +02:00
parent 1d57e50810
commit 7959a55e15

View File

@ -5700,6 +5700,9 @@ int http_process_res_common(struct session *t, struct channel *rep, int an_bit,
}
}
/* we want to have the response time before we start processing it */
t->logs.t_data = tv_ms_elapsed(&t->logs.tv_accept, &now);
if (1) {
/*
* 3: we will have to evaluate the filters.
@ -5731,6 +5734,7 @@ int http_process_res_common(struct session *t, struct channel *rep, int an_bit,
return_srv_prx_502:
rep->analysers = 0;
txn->status = 502;
t->logs.t_data = -1; /* was not a valid response */
rep->prod->flags |= SI_FL_NOLINGER;
bi_erase(rep);
stream_int_retnclose(rep->cons, http_error_message(t, HTTP_ERR_502));
@ -5788,6 +5792,7 @@ int http_process_res_common(struct session *t, struct channel *rep, int an_bit,
msg->next -= channel_forward(rep, msg->next);
msg->msg_state = HTTP_MSG_RPBEFORE;
txn->status = 0;
t->logs.t_data = -1; /* was not a response yet */
rep->analysers |= AN_RES_WAIT_HTTP | an_bit;
return 1;
}
@ -5960,8 +5965,6 @@ int http_process_res_common(struct session *t, struct channel *rep, int an_bit,
* could. Let's switch to the DATA state. *
************************************************************/
t->logs.t_data = tv_ms_elapsed(&t->logs.tv_accept, &now);
/* if the user wants to log as soon as possible, without counting
* bytes from the server, then this is the right moment. We have
* to temporarily assign bytes_out to log what we currently have.