Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
The CONNECT request don't work with HttpWebRequestand they always throw exceptions like 404 not found, or underlying connection closed. I think it is because they are HTTPS and not HTTP. So when requiring to handle CONNECT requests what exactly can be done? (Sending Connect Request and collecting back the Response) I will write the response later to a TCPClient stream.
Posted
Comments
Member 11484204 1-Mar-15 2:29am    
in c# in the console apllication to create the app

1 solution

CONNECT is a method reserved for tunelling (see: https://tools.ietf.org/html/rfc2616#section-9.9[^]).
On the other hand, HttpWebRequest implements proxy support[^].
What is your purpose with it?
 
Share this answer
 
Comments
Member 8353523 28-Feb-15 15:18pm    
I have implemented a proxy to which a browser connects and surfs the web (for unblocking regional content filtering). It is working but I am only able to handle HTTP GET and POST and not able to handling HTTPS CONNECT AND PUT using HttpWebRequest. So that is where I have stuck.
Zoltán Zörgő 28-Feb-15 15:24pm    
Still unclear.
You already have a proxy?
It is made by you or it is a ready made one?
If you use a browser with that proxy, it is working as expected?

I am asking this because CONNECT is a method not meant to be used directly as GET and POST. And PUT, DELETE (used for REST APIs in general) might not be supported or enabled by default on that proxy.

With other words while GET, POST, PUT, DELETE (and others) are meant to pass trough the proxy, CONNECT is meant for the proxy/tunnel itself. On the other hand not all proxies implement CONNECT.
Member 8353523 28-Feb-15 15:32pm    
I made a the proxy myself through TCP communication. So when you for example run chrome under the proxy (127.0.0.1, 500) it connects to it and my proxy gets the browser requests and streams back internet by decoding the TCP stream and DeSerializing it. So when I have "GET www.Yahoo.com HTTP...", I separate the GET and the URL and pass it to the HttpWebRequest. But sometime the browser requests `CONNECT us.yahoo.com:443 ...` so these cannot be handled by the `HttpWebRequest` and they throw exceptions and website does not load.
Zoltán Zörgő 28-Feb-15 16:10pm    
No, because it is intended to be porocessed by the proxy itself. Please read this RFC: https://www.ietf.org/rfc/rfc2817.txt. You need to provide the tunneling with your proxy. So you don't forward the CONNECT to the third party.
Zoltán Zörgő 28-Feb-15 16:24pm    
This c# proxy implementation might be also interesting for you: http://www.mentalis.org/soft/projects/proxy/

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900