HttpWebRequest and pipelining

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

The httpWebRequest class supposedly supports HTTP 1.1 pipelining. I wasn't
able to figure out how to send multiple GET requests pipelined together.
All I could do was set one URI, and do GetResponse, or BeginGetResponse,
which would fire off a request for just that one URI.

I need it to pipeline multiple GETs over the same connection, to test
whether our Web server properly responds to pipelined requests.

Any pointers on how to do that, would be much appreciated

Thanks
cb
 
Pipelining is transparent. If you do multiple BeginGetResponse() calls, or
multiple GetResponse() on different threads, HttpWebRequest will pipeling
requests internally.

The server has to support pipelining. Most HTTP/1.1 compliant servers
support this. As per the RFC you can only pipeling idempotent verbs, eg:
GET. POST/PUT will not be pipelined.
 
No, keep alive is required for pipelining to work, but it doesn't determine
how requests are sent.

Here is a description of what I am trying to do:
http://www.mozilla.org/projects/netlib/http/pipelining-faq.html

just in my own client, as Firefox claims IIS doesn't handle pipelined
requests correctly and doesn't even try to send pipelined requests if the
site is served by IIS.
Or if anyone knows about an available client that will send pipelined
requests to IIS, I'd be happy to try that. (Opera doesn't do it for IIS
either)

I'd like to verify the IIS behavior, with a really simple client, basically
sending off 3 requests over a single connection in a nonsequential manner.
like

GET
GET
GET
HTTP/1.1 200 OK
HTTP/1.1 200 OK
HTTP/1.1 200 OK

The aspect of squeezing all 3 GETs into a singel TCP package is not that
important to me, but the ability to send additional requests over the same
connection, before the previous requests come back is. This is ultimately for
an environment that has high latency.

Thanks
 
cb said:
I'd like to verify the IIS behavior, with a really simple client, basically
sending off 3 requests over a single connection in a nonsequential manner.
like

GET
GET
GET
HTTP/1.1 200 OK
HTTP/1.1 200 OK
HTTP/1.1 200 OK

The aspect of squeezing all 3 GETs into a singel TCP package is not that
important to me, but the ability to send additional requests over the same
connection, before the previous requests come back is. This is ultimately for
an environment that has high latency.

OK,
found it. The framework is doing all this for you under the hood, and by
default pipelining is switched on. It's just that in most normal test
situations it doesn't use pipelining.

I first set
ServicePointManager.DefaultConnectionLimit = 1
to force my client to use the same persistent connection for all requests.
Then I just send of a number of asynchronous Webrequests for different pages
from the same server.

The ServicePoint takes care of all the packaging up of the requests. I don't
think there is much in the way you can influence it. If you tell it to use
pipelining (default) it will pipeline (even put multiple requests in the same
TCP package) if it thinks it is the right thing to do.
 
Back
Top