How to implement authentication in a Proxy Server
-
24-05-2021 - |
Pregunta
I borrowed code for an http proxy server, everything works fine. Now I want to limit use of the proxy server by requiring authentication.
So, I tried the following:
On the client side:
- web client created to request page from google.
- web client uses WbProxy with username and password.
on the server, the request comes through, and I can see the headers:
- GET http://www.google.com/ HTTP/1.1
- Host: www.google.com
- Proxy-Connection: Keep-Alive
So I have the server respond to the client with:
- HTTP/1.0 407 Proxy Authentication Required
- Proxy-Authenticate: Basic realm="proxy"
At this point, I was hoping the client would then respond with the username and password used for the WebProxy credentials. But that doesn't happen.
What am I missing? How do I get my Proxy server to require authentication and ultimately to test the credentials sent?
Solución
I figured it out, had to add "\r\n\r\n" to the response back to the client. LAME!
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow