Https request via proxy- getting refresh headers

keerthik keerthi.kamalapuri at yellowbook.com
Thu Apr 8 11:19:19 EDT 2010


Hello,

I am using netty to connect to a ISA proxy and then request to read the
contents of different URLS. This process works fine for all http request but
if I follow the same procedure for https request, I get refresh header to go
to original website. my code is as follows
String url ="https://www.mysecuresite.com"
 URI uri = new URI(url);
         // Configure the client.
         ChannelFactory factory =
             new NioClientSocketChannelFactory(
                     Executors.newCachedThreadPool(),
                     Executors.newCachedThreadPool());

         ClientBootstrap bootstrap = new ClientBootstrap(factory);
         bootstrap.setPipelineFactory(new HttpClientPipelineFactory());

         // Start the connection attempt.
         ChannelFuture future = bootstrap.connect(new
InetSocketAddress("MY_ISA_Proxy", 8080));

         // Wait until the connection attempt succeeds or fails.
         Channel channel = future.awaitUninterruptibly().getChannel();
         if (!future.isSuccess()) {
             future.getCause().printStackTrace();
             factory.releaseExternalResources();
             return;
         }

         // Send the HTTP request.
         HttpRequest request = new DefaultHttpRequest(
                 HttpVersion.HTTP_1_1, HttpMethod.GET, uri.toASCIIString());
         request.addHeader(HttpHeaders.Names.HOST,"www.mysecuresite.com");
         request.addHeader(HttpHeaders.Names.USER_AGENT, "myAgent");
         request.setUri(url);
         channel.write(request);

         try { Thread.sleep(60000); } catch (Exception e) {}

         // Wait for the server to close the connection.
         channel.getCloseFuture().awaitUninterruptibly();

         // Shut down executor threads to exit.
         factory.releaseExternalResources();

I get the response as follows



STATUS: 200 OK
VERSION: HTTP/1.0

HEADER: Content-Type = text/html
HEADER: Refresh = 0; URL=https://www.mysuresite.com/

CHUNKED CONTENT {
<HTML></HTML>
} END OF CHUNKED CONTENT


- If I replace the URL with any http address it works fine. 
-If i connect to https site via netty WITHOUT using my proxy it works file
- if i use java and connect to https via proxy it works fine. The snippet is
as follows


URL server= new URL ( "https://www.mysecuresite.com/" ) ;

 	Properties systemProperties = System.getProperties (  ) ; 
    	systemProperties.setProperty("proxySet", "true");
    	 systemProperties.setProperty ( "proxyHost",""MY_ISA_Proxy" ) ; 
    	 systemProperties.setProperty ( "proxyPort","8080" ) ; 
    	 HttpURLConnection connection =  ( HttpURLConnection )
server.openConnection (  ) ;
    	 if  ( HttpURLConnection.HTTP_OK == connection.getResponseCode ()  )   
    	 {  
    		 BufferedReader rd = new BufferedReader(new
InputStreamReader(connection.getInputStream()));
    		    String line;
    		    while ((line = rd.readLine()) != null){
    		    System.out.println(line);
    		   } 
      }

This works file.

So I cannot blame proxy as I get data using java from proxy. So i think I am
doing something wrong in requesting data from https site via netty proxy.

Please help me
Keerthi
-- 
View this message in context: http://n2.nabble.com/Https-request-via-proxy-getting-refresh-headers-tp4871765p4871765.html
Sent from the Netty User Group mailing list archive at Nabble.com.


More information about the netty-users mailing list