示例#1
0
 private static void sendURIParseError(OutputStream os, boolean shouldDisconnect, Throwable e)
     throws IOException {
   StringWriter sw = new StringWriter();
   PrintWriter pw = new PrintWriter(sw);
   e.printStackTrace(pw);
   pw.close();
   String message =
       "<html><head><title>"
           + l10n("uriParseErrorTitle")
           + "</title></head><body><p>"
           + HTMLEncoder.encode(e.getMessage())
           + "</p><pre>\n"
           + sw.toString();
   sendHTMLError(os, 400, "Bad Request", message, shouldDisconnect, null);
 }
示例#2
0
 /**
  * Send an error message. Caller provides the HTTP code, reason string, and a message, which will
  * become the title and the h1'ed contents of the error page.
  */
 private static void sendError(
     OutputStream os,
     int code,
     String httpReason,
     String message,
     boolean shouldDisconnect,
     MultiValueTable<String, String> mvt)
     throws IOException {
   sendHTMLError(
       os,
       code,
       httpReason,
       "<html><head><title>" + message + "</title></head><body><h1>" + message + "</h1></body>",
       shouldDisconnect,
       mvt);
 }