01: package vicazh.hyperpool.stream.net.http;
02:
03: import java.io.*;
04: import java.net.*;
05: import java.net.Socket;
06: import vicazh.hyperpool.Start;
07: import vicazh.hyperpool.stream.net.*;
08:
09: class HttpsStream extends ClientStream {
10:
11: HttpsStream(Session session) {
12: super (session, null);
13: }
14:
15: private Socket socket;
16:
17: public void header() throws IOException {
18: super .header();
19: URL url = new URL("https://" + getFile());
20: int i = url.getPort();
21: socket = new Socket(url.getHost(), i == -1 ? url
22: .getDefaultPort() : i);
23: socket
24: .setSoTimeout(((HttpsService) connection.element).timeout);
25: outputstream = new BufferedOutputStream(socket
26: .getOutputStream());
27: session.getServer().head(getVersion(), ServerStream.OK,
28: "Connection established");
29: session.getServer().field("Proxy-agent",
30: Start.NAME + "/" + Start.VERSION);
31: session.getServer().header();
32: session.getServer().flush();
33: Transfer.start(
34: new BufferedInputStream(socket.getInputStream()),
35: session.connection.getServer());
36: }
37:
38: public vicazh.hyperpool.stream.net.Socket getSocket() {
39: return new vicazh.hyperpool.stream.net.Socket(socket);
40: }
41:
42: protected void line(String s) throws IOException {
43: }
44:
45: public void close() throws IOException {
46: try {
47: socket.close();
48: } catch (Exception e) {
49: }
50: super.close();
51: }
52:
53: }
|