tags:

views:

198

answers:

3

I have an application that posts a large file to a vendor's API and gets a response. It does so thusly:

HttpWebRequest webRequest = BuildWebRequest(..., requestParams.Data, ...);
HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();

I would like to measure the elapsed time of only the response itself (excluding the time it takes to transmit/post the large multipart/form-data).

I don't see any combination of HttpWebRequest methods or events I can tap into to separate the request upload from the response download.

Any ideas?

A: 

Unless you're sending a file the request time is going to be trivial.

Spencer Ruport
Yes, it "posts a large file." Up to 10MB, let's say.
A: 

There is no way for your calling code to tell when the response is sent from the server. The best you could get is when the first data from the response becomes available in the response stream.

David
A: 

If this is just for testing, I would use Fiddler to monitor the traffic. It can show you the type of information you want.

Here is an example output from a quick webservice call that was captured using fiddler:

== TIMING INFO ============
ClientConnected:     15:41:07:2804
ClientDoneRequest:   15:41:07:6398
Gateway Determination:  0ms
DNS Lookup:         0ms
TCP/IP Connect:      0ms
ServerGotRequest:    15:41:07:6398
ServerBeginResponse:    15:41:07:7804
ServerDoneResponse: 15:41:07:7804
ClientBeginResponse:    15:41:07:7804
ClientDoneResponse: 15:41:07:7804

If you've never used fiddler for making web service calls, make sure you add the following to your web.config:

  <system.net>
    <defaultProxy>
      <proxy  proxyaddress="http://127.0.0.1:8888" />
    </defaultProxy>
  </system.net>
AaronS