コード例 #1
0
ファイル: MessageUtils.java プロジェクト: MTuner/RiaCrawler
 public static boolean expectContent(RequestHeader request) throws MessageFormatException {
   String method = request.getMethod();
   if (!"POST".equalsIgnoreCase(method) && !"PUT".equalsIgnoreCase(method)) return false;
   String contentLength = request.getHeader(CONTENT_LENGTH);
   String transferEncoding = request.getHeader(TRANSFER_ENCODING);
   if (transferEncoding != null) return true;
   if (contentLength == null)
     throw new MessageFormatException(
         "Request content expected, but no length specified!", request.getHeader());
   try {
     int cl = Integer.parseInt(contentLength);
     if (cl < 0)
       throw new MessageFormatException(
           "Negative content length: " + contentLength, request.getHeader());
     if (cl == 0) return false;
     return true;
   } catch (NumberFormatException nfe) {
     throw new MessageFormatException(
         "Invalid content length: " + contentLength, nfe, request.getHeader());
   }
 }
コード例 #2
0
ファイル: MessageUtils.java プロジェクト: MTuner/RiaCrawler
 public static boolean isExpectContinue(RequestHeader request) throws MessageFormatException {
   return "100-continue".equalsIgnoreCase(request.getHeader("Expect"));
 }