Package vicazh.hyperpool.stream.net.http

Source Code of vicazh.hyperpool.stream.net.http.HttpsStream

package vicazh.hyperpool.stream.net.http;

import java.io.*;
import java.net.*;
import java.net.Socket;
import vicazh.hyperpool.Start;
import vicazh.hyperpool.stream.*;
import vicazh.hyperpool.stream.net.*;

class HttpsStream extends ClientStream {

  HttpsStream(Session session) {
    super(session, new NullStream());
  }

  private Socket socket;

  public void header() throws IOException {
    super.header();
    try {
      URL url = new URL("https://" + getFile());
      int i = url.getPort();
      socket = new Socket(url.getHost(), i == -1 ? url.getDefaultPort()
          : i);
      socket.setSoTimeout(((HttpsService) connection.element).timeout);
      outputstream = new BufferedOutputStream(socket.getOutputStream());
      session.getServer().head(getVersion(), ServerStream.OK,
          "Connection established");
      session.getServer().field("Proxy-agent",
          Start.SYSTEM_NAME + "/" + Start.VERSION);
      session.getServer().header();
      connection.getServer().flush();
      Transfer.start(new BufferedInputStream(socket.getInputStream()),
          connection.getServer());
    } catch (IOException e) {
      try {
        connection.getServer().close();
      } catch (Exception e1) {
      }
      throw e;
    }
  }

  public vicazh.hyperpool.stream.net.Socket getSocket() {
    return new vicazh.hyperpool.stream.net.Socket(socket);
  }

  public void close() throws IOException {
    try {
      socket.close();
    } catch (Exception e) {
    }
    super.close();
  }

}
TOP

Related Classes of vicazh.hyperpool.stream.net.http.HttpsStream

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.