home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / VPage / Java.bin / CLASSES.ZIP / sun / rmi / transport / proxy / HttpOutputStream.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-07-08  |  1.2 KB  |  35 lines

  1. package sun.rmi.transport.proxy;
  2.  
  3. import java.io.ByteArrayOutputStream;
  4. import java.io.DataOutputStream;
  5. import java.io.IOException;
  6. import java.io.OutputStream;
  7.  
  8. class HttpOutputStream extends ByteArrayOutputStream {
  9.    protected OutputStream out;
  10.    boolean responseSent = false;
  11.    private static byte[] emptyData = new byte[]{0};
  12.  
  13.    public HttpOutputStream(OutputStream var1) {
  14.       this.out = var1;
  15.    }
  16.  
  17.    public synchronized void close() throws IOException {
  18.       if (!this.responseSent) {
  19.          if (((ByteArrayOutputStream)this).size() == 0) {
  20.             ((OutputStream)this).write(emptyData);
  21.          }
  22.  
  23.          DataOutputStream var1 = new DataOutputStream(this.out);
  24.          var1.writeBytes("Content-type: application/octet-stream\r\n");
  25.          var1.writeBytes("Content-length: " + ((ByteArrayOutputStream)this).size() + "\r\n");
  26.          var1.writeBytes("\r\n");
  27.          ((ByteArrayOutputStream)this).writeTo(var1);
  28.          var1.flush();
  29.          ((ByteArrayOutputStream)this).reset();
  30.          this.responseSent = true;
  31.       }
  32.  
  33.    }
  34. }
  35.