protected 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.1 " + 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");
      }
    }
    sendConnectionHeaderIfNotAlreadyPresent(pw,header);
    if (requestMethod != Method.HEAD && chunkedTransfer) {
      sendAsChunked(outputStream,pw);
    }
 else {
      int pending=data != null ? data.available() : 0;
      sendContentLengthHeaderIfNotAlreadyPresent(pw,header,pending);
      pw.print("\r\n");
      pw.flush();
      sendAsFixedLength(outputStream,pending);
    }
    outputStream.flush();
  }
 catch (  IOException ioe) {
    ioe.printStackTrace();
  }
 finally {
    safeClose(data);
  }
}

protected 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.1 " + 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" ) ; } } sendConnectionHeaderIfNotAlreadyPresent ( pw , header ) ; if ( requestMethod != Method . HEAD && chunkedTransfer ) { sendAsChunked ( outputStream , pw ) ; } else { int pending = data != null ? data . available ( ) : 0 ; sendContentLengthHeaderIfNotAlreadyPresent ( pw , header , pending ) ; pw . print ( "\r\n" ) ; pw . flush ( ) ; sendAsFixedLength ( outputStream , pending ) ; } outputStream . flush ( ) ; } catch ( IOException ioe ) { ioe . printStackTrace ( ) ; } finally { safeClose ( data ) ; } }
sends given response to the socket .
