Https request via proxy- getting refresh headers
"Trustin Lee (이희승)"
trustin at gmail.com
Mon Apr 12 07:06:07 EDT 2010
I think you are still sending an HTTP request rather than HTTPS. In
Netty, the URL doesn't have much meaning. That is, replacing 'http'
with 'https' doesn't give you an HTTPS client automatically. You have
to configure the pipeline to initiate an SSL connection and specify 443
as the connect port instead of 80.
For more information on making an SSL connection, please refer to the
latest HTTP client example:
* HttpClient.java: http://is.gd/bptsB
* HttpClientPipelineFactory.java: http://is.gd/bptsU
I'll publish the updated example to the web site once 3.2.0.CR1 is released.
BTW, what you really want is only HTTP(S), you could use this nice
library based on Netty:
http://github.com/ning/async-http-client
HTH,
Trustin
keerthik wrote:
> 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
--
what we call human nature in actuality is human habit
http://gleamynode.net/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 260 bytes
Desc: OpenPGP digital signature
Url : http://lists.jboss.org/pipermail/netty-users/attachments/20100412/1ade403b/attachment.bin
More information about the netty-users
mailing list