How to intercept what HttpWebRequest sends?

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
 
J

Jonathan Allen

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.
 
C

Christoph Wienands

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
 
C

Christoph Wienands

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
 
G

Guest

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
 
F

Feroze [msft]

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.
----------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top