On 18/10/2010, at 18:45, Navid Mohaghegh wrote:

> Imagine a client sending an http request. I need to log the response
> time of the server from the moment it received the request till it fully
> generated the response and is ready to send back the response to client. 
> 
> Could you please help me?

Using blocking sockets, you could do something like this:

============================
# Connect and send the HTTP request
sock = connect(host)
sock.disable_Nagle's()
sock.write (request)

# Time starts to be relevant
time_start = time()

# Measure the first roundtrip
sock.read(1)
time_1st_byte = time()

# Parse 'Content-Length' and read the rest
sock.read (rest_len)
time_finish = time()
============================

So, the time to receive the first byte would be (time_1st_byte - time_start), 
and the total time to receive response and body (time_finish - time_start).

--
Octality
http://www.octality.com/

_______________________________________________
Cherokee mailing list
[email protected]
http://lists.octality.com/listinfo/cherokee

Reply via email to