Beispiel #1
0
  static {
    int versionLength = HttpVersion.HTTP_1_1.toString().length();

    for (int i = 0; i < __preprepared.length; i++) {
      HttpStatus.Code code = HttpStatus.getCode(i);
      if (code == null) continue;
      String reason = code.getMessage();
      byte[] line = new byte[versionLength + 5 + reason.length() + 2];
      HttpVersion.HTTP_1_1.toBuffer().get(line, 0, versionLength);
      line[versionLength + 0] = ' ';
      line[versionLength + 1] = (byte) ('0' + i / 100);
      line[versionLength + 2] = (byte) ('0' + (i % 100) / 10);
      line[versionLength + 3] = (byte) ('0' + (i % 10));
      line[versionLength + 4] = ' ';
      for (int j = 0; j < reason.length(); j++)
        line[versionLength + 5 + j] = (byte) reason.charAt(j);
      line[versionLength + 5 + reason.length()] = HttpTokens.CARRIAGE_RETURN;
      line[versionLength + 6 + reason.length()] = HttpTokens.LINE_FEED;

      __preprepared[i] = new PreparedResponse();
      __preprepared[i]._schemeCode = Arrays.copyOfRange(line, 0, versionLength + 5);
      __preprepared[i]._reason = Arrays.copyOfRange(line, versionLength + 5, line.length - 2);
      __preprepared[i]._responseLine = line;
    }
  }
Beispiel #2
0
 public int getCode() {
   return status.getCode();
 }
 @Test
 public void testInvalidGetCode() {
   assertNull("Invalid code: 800", HttpStatus.getCode(800));
   assertNull("Invalid code: 190", HttpStatus.getCode(190));
 }