Reputation: 2674
Has the HttpWebRequest.Timeout Property behavior changed between .NET 3.5 and 4.0? The documentation seems to imply so:
From the .NET 3.5 MSDN doc:
Timeout is the number of milliseconds that a subsequent synchronous request made with the GetResponse method waits for a response, and the GetRequestStream method waits for a stream. If the resource is not returned within the time-out period, the request throws a WebException with the Status property set to WebExceptionStatus.Timeout.
The .NET 4.0 doc adds this sentence right in the middle:
The Timeout applies to the entire request and response, not individually to the GetRequestStream and GetResponse method calls.
This seems to be a rather large change. The "entire request and response" could mean the entire time spent sending the request and receiving the response. This seems to contradict the previous sentence, since waiting for the response stream to be ready might be quick -- basically just the time for the server to retrieve/prepare the response -- but receiving the entire response over the stream could take a long time.
Has anyone compared this behavior between 3.5 and 4.0?
Upvotes: 0
Views: 292
Reputation: 4101
If you look at the code example on the .net code (msdn doc page that you reference) the request and response are two separate operations therefor the timeout operation on the request is copied to the response. So if the default is 100 ms it is 100 ms for the request and 100 ms for the response not an elapsed time of 100 for both.
Note that if you anticipate long running requests or responses consider asynchronous operations instead.
Upvotes: 1