@Test public void testNegativeValueWithOffset() { String text = "Content-Length: -1"; byte[] bytes = text.getBytes(); assertNegativeSizeException(() -> HttpUtils.trimAndDecodePositiveInt(bytes, 15, 3)); assertNegativeSizeException(() -> HttpUtils.trimAndDecodePositiveInt(bytes, 16, 2)); }
public static int trimAndDecodePositiveInt(byte[] array, int pos, int len) throws ParseException { int left = trimLeft(array, pos, len); pos += left; len -= left; len -= trimRight(array, pos, len); return decodePositiveInt(array, pos, len); }
HttpUtils { public static int trimAndDecodePositiveInt(byte[] array, int pos, int len) throws ParseException { int left = trimLeft(array, pos, len); pos += left; len -= left; len -= trimRight(array, pos, len); return decodePositiveInt(array, pos, len); } }
HttpUtils { public static int trimAndDecodePositiveInt(byte[] array, int pos, int len) throws ParseException { int left = trimLeft(array, pos, len); pos += left; len -= left; len -= trimRight(array, pos, len); return decodePositiveInt(array, pos, len); }  }
HttpUtils { public static int trimAndDecodePositiveInt(byte[] array, int pos, int len) throws ParseException { int left = trimLeft(array, pos, len); pos += left; len -= left; len -= trimRight(array, pos, len); return decodePositiveInt(array, pos, len); }  static InetAddress inetAddress(String host); static boolean isInetAddress(String host); static int skipSpaces(byte[] bytes, int pos, int end); static int parseQ(byte[] bytes, int pos, int length); static String renderQueryString(Map<String, String> q); static String renderQueryString(Map<String, String> q, String enc); static String urlEncode(String string, String enc); static String urlDecode(@Nullable String string, String enc); static int trimAndDecodePositiveInt(byte[] array, int pos, int len); @Nullable static String getFullUri(HttpRequest request, int builderCapacity); @Nullable static String getFullUri(HttpRequest request); static String getHttpErrorTitle(int code); }
HttpUtils { public static int trimAndDecodePositiveInt(byte[] array, int pos, int len) throws ParseException { int left = trimLeft(array, pos, len); pos += left; len -= left; len -= trimRight(array, pos, len); return decodePositiveInt(array, pos, len); }  static InetAddress inetAddress(String host); static boolean isInetAddress(String host); static int skipSpaces(byte[] bytes, int pos, int end); static int parseQ(byte[] bytes, int pos, int length); static String renderQueryString(Map<String, String> q); static String renderQueryString(Map<String, String> q, String enc); static String urlEncode(String string, String enc); static String urlDecode(@Nullable String string, String enc); static int trimAndDecodePositiveInt(byte[] array, int pos, int len); @Nullable static String getFullUri(HttpRequest request, int builderCapacity); @Nullable static String getFullUri(HttpRequest request); static String getHttpErrorTitle(int code); static final ParseException INVALID_Q_VALUE; }