private void sendResponse(String status,String mime,Properties header,InputStream data){
  try {
    if (status == null)     throw new Error("sendResponse(): Status can't be null.");
    OutputStream out=mySocket.getOutputStream();
    PrintWriter pw=new PrintWriter(out);
    pw.print("HTTP/1.0 " + status + " \r\n");
    if (mime != null)     pw.print("Content-Type: " + mime + "\r\n");
    if (header == null || header.getProperty("Date") == null)     pw.print("Date: " + gmtFrmt.format(new Date()) + "\r\n");
    if (header != null) {
      Enumeration e=header.keys();
      while (e.hasMoreElements()) {
        String key=(String)e.nextElement();
        String value=header.getProperty(key);
        pw.print(key + ": " + value+ "\r\n");
      }
    }
    pw.print("\r\n");
    pw.flush();
    if (data != null) {
      int pending=data.available();
      byte[] buff=new byte[2048];
      while (pending > 0) {
        int read=data.read(buff,0,((pending > 2048) ? 2048 : pending));
        if (read <= 0)         break;
        out.write(buff,0,read);
        pending-=read;
      }
    }
    out.flush();
    out.close();
    if (data != null)     data.close();
  }
 catch (  IOException ioe) {
    try {
      mySocket.close();
    }
 catch (    Throwable t) {
    }
  }
}

private void sendResponse ( String status , String mime , Properties header , InputStream data ) { try { if ( status == null ) throw new Error ( "sendResponse(): Status can't be null." ) ; OutputStream out = mySocket . getOutputStream ( ) ; PrintWriter pw = new PrintWriter ( out ) ; pw . print ( "HTTP/1.0 " + status + " \r\n" ) ; if ( mime != null ) pw . print ( "Content-Type: " + mime + "\r\n" ) ; if ( header == null || header . getProperty ( "Date" ) == null ) pw . print ( "Date: " + gmtFrmt . format ( new Date ( ) ) + "\r\n" ) ; if ( header != null ) { Enumeration e = header . keys ( ) ; while ( e . hasMoreElements ( ) ) { String key = ( String ) e . nextElement ( ) ; String value = header . getProperty ( key ) ; pw . print ( key + ": " + value + "\r\n" ) ; } } pw . print ( "\r\n" ) ; pw . flush ( ) ; if ( data != null ) { int pending = data . available ( ) ; byte [ ] buff = new byte [ 2048 ] ; while ( pending > 0 ) { int read = data . read ( buff , 0 , ( ( pending > 2048 ) ? 2048 : pending ) ) ; if ( read <= 0 ) break ; out . write ( buff , 0 , read ) ; pending -= read ; } } out . flush ( ) ; out . close ( ) ; if ( data != null ) data . close ( ) ; } catch ( IOException ioe ) { try { mySocket . close ( ) ; } catch ( Throwable t ) { } } }
sends given response to the socket .
