Hi,
In my experiments I am reading the response size with Content-length field as below: ( Traffic
server-7.0.0)
case TS_EVENT_HTTP_READ_RESPONSE_HDR:
{
if (TS_SUCCESS == TSHttpTxnServerRespGet(txn, &hdr_bufp, &hdr_loc)) {
TSMLoc loc = TSMimeHdrFieldFind(hdr_bufp, hdr_loc, "Content-Length", -1);
sd.status_code = TSHttpHdrStatusGet(hdr_bufp, hdr_loc);
if (TS_NULL_MLOC != loc) {
sd.c_len = TSMimeHdrFieldValueUintGet(hdr_bufp, hdr_loc, loc, 0 );
TSDebug("balancer", " [%" PRIu64 "] %d %d", smid, sd.status_code, sd.c_len);
}
TSHandleMLocRelease(hdr_bufp, hdr_loc, loc);
}
}
And in Transaction close event:
case TS_EVENT_HTTP_TXN_CLOSE:
{
resp_size = TSHttpTxnServerRespBodyBytesGet(txt);
TSDebug("balancer", "[%" PRIu64 "]Server response size %d", smid, resp_size);
}
The output from Traffic server:
[Jul 15 10:15:44.450] Server {0x7f7b7309b700} DIAG: (balancer) [176] 200 334496
[Jul 15 10:15:44.455] Server {0x7f7b7309b700} DIAG: (balancer) [176]Server response size 334496
I am using load balancer plugin for my experiments.
Thanks
Gandhimathi
On Jul 14, 2017, at 2:37 AM, Gaurav Bansal <zeebee48@gmail.com<mailto:zeebee48@gmail.com>>
wrote:
hi all,
I want to get the total http response size (i.e. size of headers + body). For this i tried
using below two api's :
TSHttpTxnServerRespBodyBytesGet(txnp) //always returns 0
TSHttpTxnServerRespHdrBytesGet(txnp) //seems to work fine
Are there any known issues in using the first api ? Is there any alternate way to get the
total size (headers + body) ?
thanks,
gaurav
|