title: Zip file turnout out to be empty
body: <p>I'm working on a HTTP server in Java, which for testing purposes is running under Windows 8.1.</p>
  
  <p>The way it's coded makes it so when a certain parameter is set, it changes the header of the HTTP file and sends the file through the socket with something that works kind of like:</p>
  
  <pre><code>socket.outputStream.write(filter.read());
  </code></pre>
  
  <p>Assume that the communication works fine, since I have tested it with various other filters and it works perfectly.</p>
  
  <p>One of the filters is supposed to grab the HTML file, zip it and then send it to the client, without creating the file in the server machine. This is the header:</p>
  
  <pre><code>"HTTP/1.1 200 OK\nContent-Type: application/zip\nContent-Disposition: filename=\"" + request + ".zip\"\n";
  </code></pre>
  
  <p>Afterwards, I set my filter to a class I created (which is copied below) and send the file. My problem is that even though the server is definitively sending data, the client only downloads an empty zip file, with nothing inside.</p>
  
  <p>I've been stuck with this issue for a few days, I can't seem to figure out what's wrong. I think that there's something wrong with how I create the entry or maybe how I close the outputs. I can't be sure.</p>
  
  <p>I'd really appreciate any advice that could be given to me on this issue. Thanks for your attention.</p>
  
  <pre><code>class ZipFilterInputStream extends FilterInputStream
  {
  
      protected ZipFilterInputStream(InputStream inputToFilter) throws IOException
      {
          super(inputToFilter);
  
          //Get the stuff ready for compression
          ByteArrayOutputStream out = new ByteArrayOutputStream();
          ZipOutputStream zout = new ZipOutputStream(out);
          zout.putNextEntry(new ZipEntry("file.html"));
  
          //Compress the stream
          int data = in.read();
          while (data != -1)
          {
              zout.write(data);
              data = in.read();
          }
          zout.closeEntry();
          zout.finish();
  
          //Get the stream ready for reading.
          in = new ByteArrayInputStream(out.toByteArray());
          out.close();
      }
  
      public int read() throws IOException
      {
          return in.read();
      }
  
  }    
  </code></pre>