How to intercept what HttpWebRequest sends?

  • Thread starter Thread starter Christoph Wienands
  • Start date Start date
C

Christoph Wienands

Hello everybody,

I'm currently thinking about a way how to intercept the binary data that
HttpWebRequest sends over the network. The class is a VERY helpful thing but
there are a few things that I obviously can't do with it. In particular I'd
like to have control over the header
REMOTE_ADDR. I have server application that uses REMOTE_ADDR and other
headers for identifying clients beyond cookies (which can easily be forged
or stolen). For load tests I'd have to send requests from PCs with
"different" internal IP addresses. As far as I know the REMOTE_ADDR is only
for information purposes and is not involved in any low-level network
routing and addressing.

Anybody has an idea?

Thanks, Christoph
 
I think a IHttpModule will work for you. I don't know off hand how to use
it, but I believe it can be used for intercepting both the incoming and
outgoing data streams.
 
Hi Jonathan,
I think a IHttpModule will work for you. I don't know off hand how to use
it, but I believe it can be used for intercepting both the incoming and
outgoing data streams.

thanks a lot. I'll look into that...

Christoph
 
Hi Jonathan,

Jonathan Allen said:
I think a IHttpModule will work for you. I don't know off hand how to use
it, but I believe it can be used for intercepting both the incoming and
outgoing data streams.

Unfortunately that was not what I was looking for. IHttpModule is only for
ASP.Net applications, on the server side. I need a solution on the client
side and I'm using the HttpWebRequest in the System.Net namespace.

Does anybody else have an idea?

Thanks, Christoph
 
Hi, Im nor really sure if this is what you are after, but if youre looking
for a way to set the "REFERER"-header (REMOTE_ADDR in web-apps) with code,
just set the "referer"-property of the HttpWebRequest-object:

Dim wr as Net.HttpWebRequest = Net.HttpWebRequest.Create(URI)
wr.Referer = "MY_NEW_REFERER"

/Fredrik
 
If I understand the original question correctly, he is asking for a way to
control the IP address of the outgoing connection ( as on the webserver, the
REMOTE_ADDR server variable will be equal to the ip of the client).

If what I udnerstand is correct, unfortunately you cant do this currently.
Httpwebrequest does not give you control over the outgoing ip address to
use.

Have you thought about using authentication and/or SSL with client
certificates to make sure that clients are authenticated ?

--
feroze

-----------------
This posting is provided as-is. It offers no warranties and assigns no
rights.

See http://weblogs.asp.net/feroze_daud for System.Net related posts.
----------------
 
Back
Top