You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modules-dev@httpd.apache.org by Julien FROMENT <Ju...@sagemcom.com> on 2015/11/06 15:12:40 UTC

Tracking sent responses

Hello,

 

We would like to use Apache HTTP Server to keep track of exactly what
part of the response was sent over a socket. Apache could call an API
asynchronously with the number of bytes sent over the socket for a given
request.

 

Here is the pseudo code:

  -- Client send a request

  -- Apache processes the request and send it to the backend server

  ...

  -- The backend server returns the response

  -- Apache sends the response to the client

  -- Apache calls Async API with the number of bytes sent

 

Are there any expert on this mailing list that could provide us
consulting services and guide us through the development of such
functionality?

 

Thanks in advance!

 

Julien


#
" Ce courriel et les documents qui lui sont joints peuvent contenir des
informations confidentielles ou ayant un caractè privéS'ils ne vous sont
pas destiné nous vous signalons qu'il est strictement interdit de les
divulguer, de les reproduire ou d'en utiliser de quelque maniè que ce
soit le contenu. Si ce message vous a é transmis par erreur, merci d'en
informer l'expéteur et de supprimer imméatement de votre systè
informatique ce courriel ainsi que tous les documents qui y sont attaché"


                               ******

" This e-mail and any attached documents may contain confidential or
proprietary information. If you are not the intended recipient, you are
notified that any dissemination, copying of this e-mail and any attachments
thereto or use of their contents by any means whatsoever is strictly
prohibited. If you have received this e-mail in error, please advise the
sender immediately and delete this e-mail and all attached documents
from your computer system."
#


Re: Tracking sent responses

Posted by Nick Kew <ni...@webthing.com>.
On Fri, 6 Nov 2015 09:12:40 -0500
Julien FROMENT <Ju...@sagemcom.com> wrote:

> Here is the pseudo code:
> 
>   -- Client send a request
> 
>   -- Apache processes the request and send it to the backend server
> 
>   ...
> 
>   -- The backend server returns the response
> 
>   -- Apache sends the response to the client
> 
>   -- Apache calls Async API with the number of bytes sent

Hmm, that sounds like something I wrote (not, alas, open source)
for a client many years ago.  But if you're only looking for
bytes sent, it's probably easier than that.  Before investing in
new development, consider:
 - Could you hook your notification into regular piped logging?
 - Would regular logging through an API like syslog or spread
   serve (there are third-party modules for those).
 - Would a security-oriented tool like Ironbee be complete overkill?

-- 
Nick Kew

Re: Tracking sent responses

Posted by Neil McKee <ne...@inmon.com>.
If mod_logio is loaded then mod_sflow will report that number as part of
it's standard feed.  Here's the relevant line in the sources:
https://github.com/sflow/mod-sflow/blob/master/mod_sflow.c#L1360

Neil


On Fri, Nov 6, 2015 at 8:21 AM, Eric Covener <co...@gmail.com> wrote:

> On Fri, Nov 6, 2015 at 11:18 AM, Julien FROMENT
> <Ju...@sagemcom.com> wrote:
> > Does the number of bytes sent written by the log  take into account the
> fact that a browser could cancel the request halfway through?
>
>
> The data added by mod_logio does take that into account. It's not 100%
> accurate because we cannot tell what has made it out of the box, but
> it's not just e.g. the content-length.  It does include headers as
> well.
>

Re: Tracking sent responses

Posted by Eric Covener <co...@gmail.com>.
On Fri, Nov 6, 2015 at 11:18 AM, Julien FROMENT
<Ju...@sagemcom.com> wrote:
> Does the number of bytes sent written by the log  take into account the fact that a browser could cancel the request halfway through?


The data added by mod_logio does take that into account. It's not 100%
accurate because we cannot tell what has made it out of the box, but
it's not just e.g. the content-length.  It does include headers as
well.

RE: Tracking sent responses

Posted by Julien FROMENT <Ju...@sagemcom.com>.
Thanks for the reply Sorin.

Does the number of bytes sent written by the log  take into account the fact that a browser could cancel the request halfway through?

For example, if a client request a 100MB file, and cancel the transfer after 50MB, will the log report 50MB?

Julien

-----Original Message-----
From: Sorin Manolache [mailto:sorinm@gmail.com] 
Sent: Friday, November 06, 2015 9:29 AM
To: modules-dev@httpd.apache.org
Subject: Re: Tracking sent responses

On 2015-11-06 15:12, Julien FROMENT wrote:
> Hello,
>
>
>
> We would like to use Apache HTTP Server to keep track of exactly what 
> part of the response was sent over a socket. Apache could call an API 
> asynchronously with the number of bytes sent over the socket for a 
> given request.
>
>
>
> Here is the pseudo code:
>
>    -- Client send a request
>
>    -- Apache processes the request and send it to the backend server
>
>    ...
>
>    -- The backend server returns the response
>
>    -- Apache sends the response to the client
>
>    -- Apache calls Async API with the number of bytes sent
>

Relaying the client request to a backend server may be realised with the ProxyPass and RewriteRule directives.

Apache may log the number of bytes sent. See http://httpd.apache.org/docs/current/mod/mod_log_config.html#formats,
the %B and %O flags.

The log can be configured to be

1. appended to a file
2. sent to syslog (which in turn may forward it over udp/tcp to a log-host) 3. piped to an external program

The first two options do not require any development from your part. If you really need that the number of bytes is sent to an http server, then you could write an external program that reads one line at a time from standard input and sends the line that it read to an http server.

Regards,
Sorin


#
" Ce courriel et les documents qui lui sont joints peuvent contenir des informations confidentielles ou ayant un caractè privéS'ils ne vous sont pas destiné nous vous signalons qu'il est strictement interdit de les divulguer, de les reproduire ou d'en utiliser de quelque maniè que ce soit le contenu. Si ce message vous a é transmis par erreur, merci d'en informer l'expéteur et de supprimer imméatement de votre systè informatique ce courriel ainsi que tous les documents qui y sont attaché"


                               ******

" This e-mail and any attached documents may contain confidential or proprietary information. If you are not the intended recipient, you are notified that any dissemination, copying of this e-mail and any attachments thereto or use of their contents by any means whatsoever is strictly prohibited. If you have received this e-mail in error, please advise the sender immediately and delete this e-mail and all attached documents from your computer system."
#


#
" Ce courriel et les documents qui lui sont joints peuvent contenir des
informations confidentielles ou ayant un caractè privéS'ils ne vous sont
pas destiné nous vous signalons qu'il est strictement interdit de les
divulguer, de les reproduire ou d'en utiliser de quelque maniè que ce
soit le contenu. Si ce message vous a é transmis par erreur, merci d'en
informer l'expéteur et de supprimer imméatement de votre systè
informatique ce courriel ainsi que tous les documents qui y sont attaché"


                               ******

" This e-mail and any attached documents may contain confidential or
proprietary information. If you are not the intended recipient, you are
notified that any dissemination, copying of this e-mail and any attachments
thereto or use of their contents by any means whatsoever is strictly
prohibited. If you have received this e-mail in error, please advise the
sender immediately and delete this e-mail and all attached documents
from your computer system."
#


Re: Tracking sent responses

Posted by Sorin Manolache <so...@gmail.com>.
On 2015-11-06 15:12, Julien FROMENT wrote:
> Hello,
>
>
>
> We would like to use Apache HTTP Server to keep track of exactly what
> part of the response was sent over a socket. Apache could call an API
> asynchronously with the number of bytes sent over the socket for a given
> request.
>
>
>
> Here is the pseudo code:
>
>    -- Client send a request
>
>    -- Apache processes the request and send it to the backend server
>
>    ...
>
>    -- The backend server returns the response
>
>    -- Apache sends the response to the client
>
>    -- Apache calls Async API with the number of bytes sent
>

Relaying the client request to a backend server may be realised with the 
ProxyPass and RewriteRule directives.

Apache may log the number of bytes sent. See 
http://httpd.apache.org/docs/current/mod/mod_log_config.html#formats, 
the %B and %O flags.

The log can be configured to be

1. appended to a file
2. sent to syslog (which in turn may forward it over udp/tcp to a log-host)
3. piped to an external program

The first two options do not require any development from your part. If 
you really need that the number of bytes is sent to an http server, then 
you could write an external program that reads one line at a time from 
standard input and sends the line that it read to an http server.

Regards,
Sorin