Does your plugin handle chunked encoding?

On Thu, Aug 16, 2012 at 8:14 PM, Adam Phelps <a...@opendns.com> wrote:
> I'm working on a plugin, one of the functions of which is to accurate track
> how much data is being sent to a given client, both for totals and a
> per-UserAgent count.
>
> This seems to mostly work, but I'm seeing some major discrepancies between
> what the plugin is reporting and what is actually being sent out (measured
> via collectd and iptables) when doing streaming (via youtube).  And these
> are major differences, the plugin reports 100GB for an hour of youtube
> streaming, where my other counters should closer to 600MB. The 600MB number
> seems about right for this sort of content.
>
> The method I'm using to track the totals sent are to set a global hook for
> TS_HTTP_SEND_RESPONSE_HDR_HOOK and then get and sum up the
> TS_MIME_FIELD_CONTENT_LENGTH header.  However with the youtube streaming
> this will see much larger numbers for Content-Length than even what is
> reported in the ATS log (via %<psql> in logs_xml.config).
>
> Here's how I'm getting the content length in the hook attached to
> TS_HTTP_SEND_RESPONSE_HDR_HOOK:
>
>   if (TSHttpTxnClientRespGet(txnp, &resp_bufp, &resp_loc) !=
>         TS_SUCCESS) {
>     LOG(LOG_ERROR,
>           "Error while retrieving resp header\n");
>     goto OUT;
>   }
>
>   /* Lookup the Content-Length field */
>   TSMLoc content_len_loc = TSMimeHdrFieldFind(resp_bufp, resp_loc,
>                  TS_MIME_FIELD_CONTENT_LENGTH,
>                  TS_MIME_LEN_CONTENT_LENGTH);
>   if (!content_len_loc) {
>     goto OUT;
>   }
>   int content_len_val_len;
>   const char *content_len_val =
>     TSMimeHdrFieldValueStringGet(resp_bufp, resp_loc,
>                                  content_len_loc, 0,
>                                  &content_len_val_len);
>   if (!content_len_val) {
>     LOG(LOG_ERROR, "Failed to get Content-Length value");
>     goto OUT;
>   }
>
> This is clearly not working for streaming, is there a better way to get the
> total size of the data being returned to the requesting client?
>
> - Adam

Reply via email to