01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: *
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */
18:
19: /**
20: * @author Mikhail A. Markov, Vasily Zakharov
21: * @version $Revision: 1.1.2.1 $
22: */package org.apache.harmony.rmi.transport.proxy;
23:
24: import java.io.IOException;
25: import java.io.InputStream;
26: import java.io.OutputStream;
27: import java.net.Socket;
28:
29: import org.apache.harmony.rmi.transport.SocketWrapper;
30:
31: /**
32: * Inbound HTTP socket wrapper.
33: *
34: * @author Mikhail A. Markov, Vasily Zakharov
35: * @version $Revision: 1.1.2.1 $
36: */
37: public class HttpInboundSocket extends SocketWrapper {
38:
39: /**
40: * Host to connect to.
41: */
42: private String host;
43:
44: /**
45: * Port to connect to.
46: */
47: private int port;
48:
49: /**
50: * Constructs this object by wrapping the specified socket.
51: *
52: * @param s
53: * Socket to wrap.
54: *
55: * @throws IOException
56: * If I/O error occurs.
57: */
58: public HttpInboundSocket(Socket s) throws IOException {
59: this (s, null, null);
60: }
61:
62: /**
63: * Constructs this object by wrapping the specified socket
64: * with the specified streams.
65: *
66: * @param s
67: * Socket to wrap.
68: *
69: * @param in
70: * Input stream.
71: *
72: * @param out
73: * Output stream.
74: *
75: * @throws IOException
76: * If I/O error occurs.
77: */
78: public HttpInboundSocket(Socket s, InputStream in, OutputStream out)
79: throws IOException {
80: super (s, in, out);
81: host = s.getInetAddress().getHostName();
82: port = s.getPort();
83: this .in = new HttpInputStream(this .in, true);
84: this .out = new HttpOutputStream(this .out, true, host, port);
85: }
86:
87: /**
88: * {@inheritDoc}
89: */
90: public String toString() {
91: return ("HttpInboundSocket[" + s.toString() + ", " //$NON-NLS-1$ //$NON-NLS-2$
92: + host + ':' + port + ']');
93: }
94: }
|