private void send(OutputStream outputStream){
  String mime=mimeType;
  SimpleDateFormat gmtFrmt=new SimpleDateFormat("E, d MMM yyyy HH:mm:ss 'GMT'",Locale.US);
  gmtFrmt.setTimeZone(TimeZone.getTimeZone("GMT"));
  try {
    if (status == null) {
      throw new Error("sendResponse(): Status can't be null.");
    }
    PrintWriter pw=new PrintWriter(outputStream);
    pw.print("HTTP/1.0 " + status.getDescription() + " \r\n");
    if (mime != null) {
      pw.print("Content-Type: " + mime + "\r\n");
    }
    if (header == null || header.get("Date") == null) {
      pw.print("Date: " + gmtFrmt.format(new Date()) + "\r\n");
    }
    if (header != null) {
      for (      String key : header.keySet()) {
        String value=header.get(key);
        pw.print(key + ": " + value+ "\r\n");
      }
    }
    pw.print("\r\n");
    pw.flush();
    if (data != null) {
      int pending=data.available();
      int BUFFER_SIZE=16 * 1024;
      byte[] buff=new byte[BUFFER_SIZE];
      while (pending > 0) {
        int read=data.read(buff,0,((pending > BUFFER_SIZE) ? BUFFER_SIZE : pending));
        if (read <= 0) {
          break;
        }
        outputStream.write(buff,0,read);
        pending-=read;
      }
    }
    outputStream.flush();
    outputStream.close();
    if (data != null)     data.close();
  }
 catch (  IOException ioe) {
  }
}

private void send ( OutputStream outputStream ) { String mime = mimeType ; SimpleDateFormat gmtFrmt = new SimpleDateFormat ( "E, d MMM yyyy HH:mm:ss 'GMT'" , Locale . US ) ; gmtFrmt . setTimeZone ( TimeZone . getTimeZone ( "GMT" ) ) ; try { if ( status == null ) { throw new Error ( "sendResponse(): Status can't be null." ) ; } PrintWriter pw = new PrintWriter ( outputStream ) ; pw . print ( "HTTP/1.0 " + status . getDescription ( ) + " \r\n" ) ; if ( mime != null ) { pw . print ( "Content-Type: " + mime + "\r\n" ) ; } if ( header == null || header . get ( "Date" ) == null ) { pw . print ( "Date: " + gmtFrmt . format ( new Date ( ) ) + "\r\n" ) ; } if ( header != null ) { for ( String key : header . keySet ( ) ) { String value = header . get ( key ) ; pw . print ( key + ": " + value + "\r\n" ) ; } } pw . print ( "\r\n" ) ; pw . flush ( ) ; if ( data != null ) { int pending = data . available ( ) ; int BUFFER_SIZE = 16 * 1024 ; byte [ ] buff = new byte [ BUFFER_SIZE ] ; while ( pending > 0 ) { int read = data . read ( buff , 0 , ( ( pending > BUFFER_SIZE ) ? BUFFER_SIZE : pending ) ) ; if ( read <= 0 ) { break ; } outputStream . write ( buff , 0 , read ) ; pending -= read ; } } outputStream . flush ( ) ; outputStream . close ( ) ; if ( data != null ) data . close ( ) ; } catch ( IOException ioe ) { } }
sends given response to the socket .
