473,395 Members | 1,497 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Proxy server with HttpListener

Hello,

I need to write a simple proxy server.
What I want to do is to use HttpListener to get requests from the
browser, add some proxy information and some other stuff and send the
request to the internet.
Then I want to send the answer back to the browser...
Sounds simple...

But how can I do this?

Has anyone done this before? Is there an example?
I already tried to find something but I had no luck so far...
Alle samples I found so far show some really basic information, but
nothing that really helped me...

How can I send the HttpListenerRequest to the internet and put the
answer back in the HttpListenerResponse?

Thanks for your help!

Jul 11 '06 #1
7 15344
I had tried this but i would not recommend to use it as HTTPListener
gives strange behaviour and you wont be able to get your proxy at work
completely. still if you wanna try your luck then, You can forward the
request got from HTTPListenerRequest using HTTPWebRequest class and
get the response back from the web server using HTTPWebResponse class,
then you can write back this response to the HTTPListenerResponse
object.

After appx 2 months of work i wasnt able to solve some errors of
HTTPListener so then i changed my approach and shifted towards sockets.
For examples in .NET you can see the source code of Mentalis proxy at
http://www.mentalis.org/soft/projects/proxy/

Good luck

/Sadeeq

Pro1712 wrote:
Hello,

I need to write a simple proxy server.
What I want to do is to use HttpListener to get requests from the
browser, add some proxy information and some other stuff and send the
request to the internet.
Then I want to send the answer back to the browser...
Sounds simple...

But how can I do this?

Has anyone done this before? Is there an example?
I already tried to find something but I had no luck so far...
Alle samples I found so far show some really basic information, but
nothing that really helped me...

How can I send the HttpListenerRequest to the internet and put the
answer back in the HttpListenerResponse?

Thanks for your help!
Jul 12 '06 #2
Thanks for your answer!

I looked at the sample.
It's written for .NET 1.0. Did you update it for .NET 2.0?
It will not work for IPv6. But this is necessary for my project...

Do yout know any other samples?

Thanks!!!
Sadiq schrieb:
I had tried this but i would not recommend to use it as HTTPListener
gives strange behaviour and you wont be able to get your proxy at work
completely. still if you wanna try your luck then, You can forward the
request got from HTTPListenerRequest using HTTPWebRequest class and
get the response back from the web server using HTTPWebResponse class,
then you can write back this response to the HTTPListenerResponse
object.

After appx 2 months of work i wasnt able to solve some errors of
HTTPListener so then i changed my approach and shifted towards sockets.
For examples in .NET you can see the source code of Mentalis proxy at
http://www.mentalis.org/soft/projects/proxy/

Good luck

/Sadeeq

Pro1712 wrote:
Hello,

I need to write a simple proxy server.
What I want to do is to use HttpListener to get requests from the
browser, add some proxy information and some other stuff and send the
request to the internet.
Then I want to send the answer back to the browser...
Sounds simple...

But how can I do this?

Has anyone done this before? Is there an example?
I already tried to find something but I had no luck so far...
Alle samples I found so far show some really basic information, but
nothing that really helped me...

How can I send the HttpListenerRequest to the internet and put the
answer back in the HttpListenerResponse?

Thanks for your help!
Jul 13 '06 #3
Hi,
Yes its written in .NET 1.0 but it doesnt require much modifications
for .NET 2.0 if you are only using it as HTTP Proxy, you need only few
classes in that case. In my case yes i considerably changed them to
suit my needs and rewritten the classes in VB.NET and .NET 2.0 instead
of C#.
I am not sure whether it will work with IPV6 or not, you can check it.
The point is that you can get the basic idea and then write your own.
I dont think there is any other open source proxy that is made in .NET.
You can find many in Java or other languges.

Best Regards

/sadeeq
Pro1712 wrote:
Thanks for your answer!

I looked at the sample.
It's written for .NET 1.0. Did you update it for .NET 2.0?
It will not work for IPv6. But this is necessary for my project...

Do yout know any other samples?

Thanks!!!
Sadiq schrieb:
I had tried this but i would not recommend to use it as HTTPListener
gives strange behaviour and you wont be able to get your proxy at work
completely. still if you wanna try your luck then, You can forward the
request got from HTTPListenerRequest using HTTPWebRequest class and
get the response back from the web server using HTTPWebResponse class,
then you can write back this response to the HTTPListenerResponse
object.

After appx 2 months of work i wasnt able to solve some errors of
HTTPListener so then i changed my approach and shifted towards sockets.
For examples in .NET you can see the source code of Mentalis proxy at
http://www.mentalis.org/soft/projects/proxy/

Good luck

/Sadeeq

Pro1712 wrote:
Hello,
>
I need to write a simple proxy server.
What I want to do is to use HttpListener to get requests from the
browser, add some proxy information and some other stuff and send the
request to the internet.
Then I want to send the answer back to the browser...
Sounds simple...
>
But how can I do this?
>
Has anyone done this before? Is there an example?
I already tried to find something but I had no luck so far...
Alle samples I found so far show some really basic information, but
nothing that really helped me...
>
How can I send the HttpListenerRequest to the internet and put the
answer back in the HttpListenerResponse?
>
Thanks for your help!
Jul 13 '06 #4
Hello,

how can I add authentification to the HttpClient?

How did you convert the function IPAddress.Address to .NET 2.0?

Can you help me?

Thanks for your help!

Sadiq schrieb:
Hi,
Yes its written in .NET 1.0 but it doesnt require much modifications
for .NET 2.0 if you are only using it as HTTP Proxy, you need only few
classes in that case. In my case yes i considerably changed them to
suit my needs and rewritten the classes in VB.NET and .NET 2.0 instead
of C#.
I am not sure whether it will work with IPV6 or not, you can check it.
The point is that you can get the basic idea and then write your own.
I dont think there is any other open source proxy that is made in .NET.
You can find many in Java or other languges.

Best Regards

/sadeeq
Pro1712 wrote:
Thanks for your answer!

I looked at the sample.
It's written for .NET 1.0. Did you update it for .NET 2.0?
It will not work for IPv6. But this is necessary for my project...

Do yout know any other samples?

Thanks!!!
Sadiq schrieb:
I had tried this but i would not recommend to use it as HTTPListener
gives strange behaviour and you wont be able to get your proxy at work
completely. still if you wanna try your luck then, You can forward the
request got from HTTPListenerRequest using HTTPWebRequest class and
get the response back from the web server using HTTPWebResponse class,
then you can write back this response to the HTTPListenerResponse
object.
>
After appx 2 months of work i wasnt able to solve some errors of
HTTPListener so then i changed my approach and shifted towards sockets.
For examples in .NET you can see the source code of Mentalis proxy at
http://www.mentalis.org/soft/projects/proxy/
>
Good luck
>
/Sadeeq
>
Pro1712 wrote:
Hello,

I need to write a simple proxy server.
What I want to do is to use HttpListener to get requests from the
browser, add some proxy information and some other stuff and send the
request to the internet.
Then I want to send the answer back to the browser...
Sounds simple...

But how can I do this?

Has anyone done this before? Is there an example?
I already tried to find something but I had no luck so far...
Alle samples I found so far show some really basic information, but
nothing that really helped me...

How can I send the HttpListenerRequest to the internet and put the
answer back in the HttpListenerResponse?

Thanks for your help!
Jul 18 '06 #5
Hello,
Do you mean Authentication to the proxy? or to any website using the
proxy..
There are authentication classes in the proxy project like
"AuthenticaionList.cs", AuthBase.cs, AuthUserPass.cs etc...have a look
if it works for you. otherwise you have to write your own class for
authentication and call it before the HTTPClient class.

Use IPAddress.Parse. ( or IPAddress.Equals)

Regards,
Sadeeq

Pro1712 wrote:
Hello,

how can I add authentification to the HttpClient?

How did you convert the function IPAddress.Address to .NET 2.0?

Can you help me?

Thanks for your help!

Sadiq schrieb:
Hi,
Yes its written in .NET 1.0 but it doesnt require much modifications
for .NET 2.0 if you are only using it as HTTP Proxy, you need only few
classes in that case. In my case yes i considerably changed them to
suit my needs and rewritten the classes in VB.NET and .NET 2.0 instead
of C#.
I am not sure whether it will work with IPV6 or not, you can check it.
The point is that you can get the basic idea and then write your own.
I dont think there is any other open source proxy that is made in .NET.
You can find many in Java or other languges.

Best Regards

/sadeeq
Pro1712 wrote:
Thanks for your answer!
>
I looked at the sample.
It's written for .NET 1.0. Did you update it for .NET 2.0?
It will not work for IPv6. But this is necessary for my project...
>
Do yout know any other samples?
>
Thanks!!!
>
>
Sadiq schrieb:
>
I had tried this but i would not recommend to use it as HTTPListener
gives strange behaviour and you wont be able to get your proxy at work
completely. still if you wanna try your luck then, You can forward the
request got from HTTPListenerRequest using HTTPWebRequest class and
get the response back from the web server using HTTPWebResponse class,
then you can write back this response to the HTTPListenerResponse
object.

After appx 2 months of work i wasnt able to solve some errors of
HTTPListener so then i changed my approach and shifted towards sockets.
For examples in .NET you can see the source code of Mentalis proxy at
http://www.mentalis.org/soft/projects/proxy/

Good luck

/Sadeeq

Pro1712 wrote:
Hello,
>
I need to write a simple proxy server.
What I want to do is to use HttpListener to get requests from the
browser, add some proxy information and some other stuff and send the
request to the internet.
Then I want to send the answer back to the browser...
Sounds simple...
>
But how can I do this?
>
Has anyone done this before? Is there an example?
I already tried to find something but I had no luck so far...
Alle samples I found so far show some really basic information, but
nothing that really helped me...
>
How can I send the HttpListenerRequest to the internet and put the
answer back in the HttpListenerResponse?
>
Thanks for your help!
Jul 20 '06 #6
Hi,

What I want to do is this:
My browser makes a request to the Proxy. The Proxy authenticates to the
company's proxy and sends the request to the company's proxy. This
proxy connects to the destination site and gets the pages.

The class HttpClient tries to connect directly to the destination. This
of course fails.
So my problem is to authenticate to the company's proxy and forward the
request and then receive the answer and send it back to the browser.
I have no idea how to do this...

Thanks!
Sadiq schrieb:
Hello,
Do you mean Authentication to the proxy? or to any website using the
proxy..
There are authentication classes in the proxy project like
"AuthenticaionList.cs", AuthBase.cs, AuthUserPass.cs etc...have a look
if it works for you. otherwise you have to write your own class for
authentication and call it before the HTTPClient class.

Use IPAddress.Parse. ( or IPAddress.Equals)

Regards,
Sadeeq

Pro1712 wrote:
Hello,

how can I add authentification to the HttpClient?

How did you convert the function IPAddress.Address to .NET 2.0?

Can you help me?

Thanks for your help!

Sadiq schrieb:
Hi,
Yes its written in .NET 1.0 but it doesnt require much modifications
for .NET 2.0 if you are only using it as HTTP Proxy, you need only few
classes in that case. In my case yes i considerably changed them to
suit my needs and rewritten the classes in VB.NET and .NET 2.0 instead
of C#.
I am not sure whether it will work with IPV6 or not, you can check it.
The point is that you can get the basic idea and then write your own.
I dont think there is any other open source proxy that is made in .NET.
You can find many in Java or other languges.
>
Best Regards
>
/sadeeq
>
>
Pro1712 wrote:
Thanks for your answer!

I looked at the sample.
It's written for .NET 1.0. Did you update it for .NET 2.0?
It will not work for IPv6. But this is necessary for my project...

Do yout know any other samples?

Thanks!!!


Sadiq schrieb:

I had tried this but i would not recommend to use it as HTTPListener
gives strange behaviour and you wont be able to get your proxy at work
completely. still if you wanna try your luck then, You can forward the
request got from HTTPListenerRequest using HTTPWebRequest class and
get the response back from the web server using HTTPWebResponse class,
then you can write back this response to the HTTPListenerResponse
object.
>
After appx 2 months of work i wasnt able to solve some errors of
HTTPListener so then i changed my approach and shifted towards sockets.
For examples in .NET you can see the source code of Mentalis proxy at
http://www.mentalis.org/soft/projects/proxy/
>
Good luck
>
/Sadeeq
>
Pro1712 wrote:
Hello,

I need to write a simple proxy server.
What I want to do is to use HttpListener to get requests from the
browser, add some proxy information and some other stuff and send the
request to the internet.
Then I want to send the answer back to the browser...
Sounds simple...

But how can I do this?

Has anyone done this before? Is there an example?
I already tried to find something but I had no luck so far...
Alle samples I found so far show some really basic information, but
nothing that really helped me...

How can I send the HttpListenerRequest to the internet and put the
answer back in the HttpListenerResponse?

Thanks for your help!
Jul 20 '06 #7
hi,
well you have to modify the code. You can write your own authentication
class using sockets that will write the authentication details to your
company proxy..(obviously that would be running on some network port,
so you need to send and recieve data on that port using your socket in
your authenticaion class).

Now when you recieve first request in HTTPClient Class then instead of
forwarding it to the remote host directly, first you call your
authentication class using whatever credintials you provide, that class
will write the credentials to your company proxy and recieves the
response, once you get the resposne then you need to simply forward
that captured HTTP request to your company proxy. Instead of the remote
host address you need to initilize your remotehost in HTTPClient class
to the IP Address and port of your company proxy...rest it will handle
itself.....

hope this helps..


Pro1712 wrote:
Hi,

What I want to do is this:
My browser makes a request to the Proxy. The Proxy authenticates to the
company's proxy and sends the request to the company's proxy. This
proxy connects to the destination site and gets the pages.

The class HttpClient tries to connect directly to the destination. This
of course fails.
So my problem is to authenticate to the company's proxy and forward the
request and then receive the answer and send it back to the browser.
I have no idea how to do this...

Thanks!
Sadiq schrieb:
Hello,
Do you mean Authentication to the proxy? or to any website using the
proxy..
There are authentication classes in the proxy project like
"AuthenticaionList.cs", AuthBase.cs, AuthUserPass.cs etc...have a look
if it works for you. otherwise you have to write your own class for
authentication and call it before the HTTPClient class.

Use IPAddress.Parse. ( or IPAddress.Equals)

Regards,
Sadeeq

Pro1712 wrote:
Hello,
>
how can I add authentification to the HttpClient?
>
How did you convert the function IPAddress.Address to .NET 2.0?
>
Can you help me?
>
Thanks for your help!
>
>
>
Sadiq schrieb:
>
Hi,
Yes its written in .NET 1.0 but it doesnt require much modifications
for .NET 2.0 if you are only using it as HTTP Proxy, you need only few
classes in that case. In my case yes i considerably changed them to
suit my needs and rewritten the classes in VB.NET and .NET 2.0 instead
of C#.
I am not sure whether it will work with IPV6 or not, you can check it.
The point is that you can get the basic idea and then write your own.
I dont think there is any other open source proxy that is made in .NET.
You can find many in Java or other languges.

Best Regards

/sadeeq


Pro1712 wrote:
Thanks for your answer!
>
I looked at the sample.
It's written for .NET 1.0. Did you update it for .NET 2.0?
It will not work for IPv6. But this is necessary for my project...
>
Do yout know any other samples?
>
Thanks!!!
>
>
Sadiq schrieb:
>
I had tried this but i would not recommend to use it as HTTPListener
gives strange behaviour and you wont be able to get your proxy at work
completely. still if you wanna try your luck then, You can forward the
request got from HTTPListenerRequest using HTTPWebRequest class and
get the response back from the web server using HTTPWebResponse class,
then you can write back this response to the HTTPListenerResponse
object.

After appx 2 months of work i wasnt able to solve some errors of
HTTPListener so then i changed my approach and shifted towards sockets.
For examples in .NET you can see the source code of Mentalis proxy at
http://www.mentalis.org/soft/projects/proxy/

Good luck

/Sadeeq

Pro1712 wrote:
Hello,
>
I need to write a simple proxy server.
What I want to do is to use HttpListener to get requests from the
browser, add some proxy information and some other stuff and send the
request to the internet.
Then I want to send the answer back to the browser...
Sounds simple...
>
But how can I do this?
>
Has anyone done this before? Is there an example?
I already tried to find something but I had no luck so far...
Alle samples I found so far show some really basic information, but
nothing that really helped me...
>
How can I send the HttpListenerRequest to the internet and put the
answer back in the HttpListenerResponse?
>
Thanks for your help!
Jul 24 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Fuzzyman | last post by:
In a nutshell - the question I'm asking is, how do I make a socket conenction go via a proxy server ? All our internet traffic has to go through a proxy-server at location 'dav-serv:8080' and I...
6
by: harry | last post by:
Hi, I have a program that runs on multiple client pc's. Occasionally one or more of those pc's use VPN to connect to another corporate network. When using VPN they need to set proxy server in...
1
by: joicedony | last post by:
Hey everybody, I am joice, College student. I am doing the project in C# .Net. The title of PROXY SERVER. Now my doubt is, I will get the request from the client, ie) the request is...
9
by: Codex Twin | last post by:
I am re-sending this in the hope that it might illicit a response. I have a corporate client who forces their workstations to get the proxy server details using an automatic proxy discovery script....
1
by: Antimon | last post by:
Hi, Anyone using the new System.Net.HttpListener class included in 2.0? How about the performance? And can it register for example "http://host:80/app" to use with iis running website on...
3
by: Martin | last post by:
How does one set up basic authentication on an HttpListener? I know I need to set the HttpListener.AuthenticationSchemes to AuthenticationSchemes.Basic but then I'm unsure how and against what...
1
by: Danny | last post by:
Can anyone point me in the right direction to create a simple web server? I need to create a simple application that receives a HTTP GET request with parameters and returns back an XML string. ...
1
by: =?Utf-8?B?V2lsZCBXaWxkIE1pa2U=?= | last post by:
I have a windows service implementation that creates an HttpListener in OnStart to help capture port conflict issues while starting vs. when the service is already started. On Windows 2003 servers...
3
by: Jon Berry | last post by:
Does the .NET framework provide any type of HTTP server class that I can embed in my application? Thanks!
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.