diff --git a/src/main/java/io/vertx/core/http/impl/HttpUtils.java b/src/main/java/io/vertx/core/http/impl/HttpUtils.java index de10da83aec..608f36ba47d 100644 --- a/src/main/java/io/vertx/core/http/impl/HttpUtils.java +++ b/src/main/java/io/vertx/core/http/impl/HttpUtils.java @@ -19,6 +19,7 @@ import io.netty.handler.codec.http2.Http2Settings; import io.netty.util.AsciiString; import io.netty.util.CharsetUtil; +import io.netty.util.internal.PlatformDependent; import io.vertx.core.AsyncResult; import io.vertx.core.Future; import io.vertx.core.Handler; @@ -882,7 +883,9 @@ private static void validateAsciiHeaderValue(AsciiString value) { int off = value.arrayOffset(); int end = off + length; - for (int index = off; index < end; index++) { + // DON'T REMOVE 'off == 0? 0 : off' as it's a micro-optimization to reduce the range checks + // since AsciiString(s) often (if not always) have offset == 0 + for (int index = off == 0? 0 : off; index < end; index++) { int latinChar = asciiChars[index] & 0xFF; if (latinChar == 0x7F) { throw new IllegalArgumentException("a header value contains a prohibited character '127': " + value);