1 28 29 package com.caucho.vfs; 30 31 import java.io.IOException ; 32 import java.net.SocketException ; 33 import java.util.Iterator ; 34 import java.util.logging.Logger ; 35 36 39 class HttpStreamWrapper extends StreamImpl 40 { 41 private static final Logger log 42 = Logger.getLogger(HttpStream.class.getName()); 43 44 private HttpStream _stream; 45 46 49 HttpStreamWrapper(HttpStream stream) 50 throws IOException 51 { 52 _stream = stream; 53 } 54 55 58 public void setSSL(boolean isSSL) 59 { 60 _stream.setSSL(isSSL); 61 } 62 63 66 public boolean isSSL() 67 { 68 return _stream.isSSL(); 69 } 70 71 74 public void setMethod(String method) 75 { 76 _stream.setMethod(method); 77 } 78 79 82 public void setHead(boolean isHead) 83 { 84 _stream.setHead(isHead); 85 } 86 87 90 public String getHost() 91 { 92 return _stream.getHost(); 93 } 94 95 98 public int getPort() 99 { 100 return _stream.getPort(); 101 } 102 103 109 public Object getAttribute(String name) 110 throws IOException 111 { 112 if (_stream != null) 113 return _stream.getAttribute(name); 114 else 115 return null; 116 } 117 118 121 public Iterator getAttributeNames() 122 throws IOException 123 { 124 if (_stream != null) 125 return _stream.getAttributeNames(); 126 else 127 return null; 128 } 129 130 133 public void setAttribute(String name, Object value) 134 { 135 if (_stream != null) 136 _stream.setAttribute(name, value); 137 } 138 139 142 public void removeAttribute(String name) 143 { 144 if (_stream != null) 145 _stream.removeAttribute(name); 146 } 147 148 151 public void setSocketTimeout(long timeout) 152 throws SocketException 153 { 154 if (_stream != null) 155 _stream.setSocketTimeout(timeout); 156 } 157 158 161 public boolean canWrite() 162 { 163 if (_stream != null) 164 return _stream.canWrite(); 165 else 166 return false; 167 } 168 169 177 public void write(byte []buf, int offset, int length, boolean isEnd) 178 throws IOException 179 { 180 if (_stream != null) 181 _stream.write(buf, offset, length, isEnd); 182 } 183 184 187 public boolean canRead() 188 { 189 if (_stream != null) 190 return _stream.canRead(); 191 else 192 return false; 193 } 194 195 199 public int read(byte []buf, int offset, int length) throws IOException 200 { 201 if (_stream != null) 202 return _stream.read(buf, offset, length); 203 else 204 return -1; 205 } 206 207 210 public int getAvailable() throws IOException 211 { 212 if (_stream != null) 213 return _stream.getAvailable(); 214 else 215 return -1; 216 } 217 218 221 public void close() throws IOException 222 { 223 HttpStream stream = _stream; 224 _stream = null; 225 226 if (stream != null) 227 stream.close(); 228 } 229 } 230 | Popular Tags |