public static void setContentLength(HttpServletResponse sres, long length) {
   if (length <= Integer.MAX_VALUE) {
     sres.setContentLength((int) length);
   } else {
     sres.addHeader("Content-Length", Long.toString(length));
   }
 }
Esempio n. 2
0
 public void handleContentHeader(String name, String value) {
   if (name.startsWith("Content-") && !value.isEmpty()) {
     if (name.equals("Content-Type")) {
       try {
         contentType = new ContentType(value);
       } catch (javax.mail.internet.ParseException ex) {
         throw new ESXXException(400, "Invalid Content-Type header: " + ex.getMessage(), ex);
       }
     } else if (name.equals("Content-Length")) {
       contentLength = Long.parseLong(value);
     } else {
       throw new ESXXException(501, "Unsupported Content header: " + name);
     }
   }
 }