1 // Copyright 2000-2005 the Contributors, as shown in the revision logs.
2 // Licensed under the Apache Public Source License 2.0 ("the License").
3 // You may not use this file except in compliance with the License.
5 package org.ibex.net.ssl;
7 import org.ibex.net.SSL;
11 public static void main(String[] args) throws Exception {
13 if(args.length < 2) { System.err.println("Usage: SSL host port"); }
14 String host = args[0];
15 int port = Integer.parseInt(args[1]);
16 SSL ssl = new SSL(host,port);
18 ssl.getOutputStream().write(SSL.getBytes("GET / HTTP/1.0\r\nHost: " + host + "\r\n\r\n"));
19 cat(ssl.getInputStream());
23 ssl = new SSL(host,port,ssl.getSessionState());
24 ssl.getOutputStream().write(SSL.getBytes("GET / HTTP/1.0\r\nHost: " + host + "\r\n\r\n"));
25 cat(ssl.getInputStream());
28 private static void cat(InputStream is) throws IOException {
29 BufferedReader br = new BufferedReader(new InputStreamReader(is));
33 while((line = br.readLine()) != null && --count >= 0) System.out.println(line);
34 } catch(SSL.PrematureCloseExn e) { /* ignore */ }