2

Hello everyone and thanks for reading.

For means of QA, I want to setup an application that could handle and manage the requests and the data sent through the internet from an especific running application.

More specifically, I want to be able to redirect a few urls, not every one, to work via a "proxy application", so if I have an application that requests http://www.google.com AND http://www.google.com/search, I would want to redirect only the second one poiting to the relative path /search.

I hope you get the idea. Do you guys have any ideas for an easy implementation and maybe an existing framework to accomplish that? I would be thankful if you give me at least some piece of code with an example.

Thanks in advance.

Update: In fact, I needed to build an application that could somehow be "attached" to and hijack an existing connection between the already developed application and the data server so it could listen and modify the data sent through this connection. I know its hard to accomplish in a high level language like c# but I just wanted to make sure

Denis Brat
  • 487
  • 5
  • 14

1 Answers1

2

I'm not sure I follow you correctly... you want to redirect certain URLs to a "proxy application"??? Not a proxy server?

If you want to redirect to a proxy server then you can do this:

HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.google.com/search/");
request.proxy = new WebProxy("http://proxyurl");
HttpWebResponse myWebResponse=(HttpWebResponse)myWebRequest.GetResponse();

Or without a proxy server:

HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.google.com/");
HttpWebResponse myWebResponse=(HttpWebResponse)myWebRequest.GetResponse();

You can let a "proxy application" serve the url, but that's a completely different story. In that case you will need some method of communication between your application and the other application. Your app can connect to the other app via TCP, via WCF or via Pipes. You send the URL to the other application and it serves it.

Then comes the other piece: does the proxy application serve the page back to your request handling application or does it serve it to the client? So how is the client communicating with your request handling application?

Update It sounds like you're looking for something like Fiddler:

Fiddler enables you to inspect all HTTP traffic, set breakpoints, and "fiddle" with incoming or outgoing data. Fiddler is much simpler to use than NetMon or other network debuggers because it exposes only HTTP traffic and does so in a user-friendly format.

In general you might want to look into traffic interception.

Community
  • 1
  • 1
Kiril
  • 39,672
  • 31
  • 167
  • 226
  • Thanks for efforts. In fact, I needed to build an application that could somehow be "attached" to and hijack an existing connection between the already developed application and the data server so it could listen and **modify** the data sent through this connection. I know its hard to accomplish in a high level language like c# but I just wanted to make sure. – Denis Brat May 10 '11 at 03:27
  • @Denis :)... It sounds like you might be looking for something like Fiddler... I've updated the answer for you. – Kiril May 10 '11 at 05:26
  • It looks like exactly what I need. Just need to play around with it a little and read its documentation. Thanks a lot for all your efforts in helping me, even with the unclear question. Thanks! – Denis Brat May 10 '11 at 06:25