I try to do proxy with the HttpURLConnection class
843811Jun 10 2003 — edited Jun 12 2003Hello,
I try do proxy with java process with the HttpURLConnection class.
The goal is :
A HTTP browser with my java process in HTTP proxy, this browser sends its request to my java process (because we configure it like default proxy) and my java process sends this request (with HttpUrlConnection) to server (and same way for response).
My problem is :
When I try to access to HTML page with http access, the server sends 'HTTP 401 Unauthorized' with header field ' WWW-Authenticate: Basic realm="/something" ', then HttpURLConnection throws an exception (in the method getInputStream) see below.
My questions are :
- How to do to force the HttpURLConnection class to not throw this exception?
- And how to force the HttpURLConnection class to send this response to HTML browser?
thank a lot
log:
java.io.FileNotFoundException: http://somewhere/
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:549)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:230)
at com.francetelecom.proxy.ProxyServlet.proxy(ProxyServlet.java:584)
at com.francetelecom.proxy.ProxyServlet.callProxy(ProxyServlet.java:971)
at com.francetelecom.proxy.ProxyServlet.doGet(ProxyServlet.java:212)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:126)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:103)
at com.caucho.server.http.FilterChainServlet.doFilter(FilterChainServlet.java:96)
at com.caucho.server.http.Invocation.service(Invocation.java:315)
at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:246)
at com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:164)
at com.caucho.server.TcpConnection.run(TcpConnection.java:139)
at java.lang.Thread.run(Thread.java:484)