Skip to content

Commit

Permalink
Move deprecated HTTP headers validation constants to HttpHeadersInternal
Browse files Browse the repository at this point in the history
  • Loading branch information
vietj committed Dec 17, 2024
1 parent 6959a92 commit ff4646b
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 22 deletions.
9 changes: 0 additions & 9 deletions vertx-core/src/main/java/io/vertx/core/http/HttpHeaders.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import io.vertx.codegen.annotations.VertxGen;
import io.vertx.core.MultiMap;
import io.vertx.core.http.impl.headers.HeadersMultiMap;
import io.vertx.core.impl.SysProps;

/**
* Contains a bunch of useful HTTP headers stuff:
Expand All @@ -35,14 +34,6 @@
@VertxGen
public interface HttpHeaders {

/** JVM system property that disables HTTP headers validation, don't use this in production. */
@Deprecated
String DISABLE_HTTP_HEADERS_VALIDATION_PROP_NAME = SysProps.DISABLE_HTTP_HEADERS_VALIDATION.name;

/** Constant that disables HTTP headers validation, this is a constant so the JIT can eliminate validation code. */
@Deprecated
boolean DISABLE_HTTP_HEADERS_VALIDATION = SysProps.DISABLE_HTTP_HEADERS_VALIDATION.getBoolean();

/**
* Accept header name
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import io.vertx.core.http.HttpVersion;
import io.vertx.core.internal.ContextInternal;
import io.vertx.core.internal.PromiseInternal;
import io.vertx.core.internal.http.HttpHeadersInternal;
import io.vertx.core.net.*;
import io.vertx.core.internal.net.NetClientInternal;
import io.vertx.core.net.impl.NetSocketImpl;
Expand Down Expand Up @@ -195,7 +196,7 @@ private void applyHttp1xConnectionOptions(ChannelPipeline pipeline) {
options.getMaxHeaderSize(),
options.getMaxChunkSize(),
false,
!HttpHeaders.DISABLE_HTTP_HEADERS_VALIDATION,
!HttpHeadersInternal.DISABLE_HTTP_HEADERS_VALIDATION,
options.getDecoderInitialBufferSize()));
if (options.isDecompressionSupported()) {
pipeline.addLast("inflater", new HttpContentDecompressor(false));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
package io.vertx.core.http.impl;

import io.netty.handler.codec.http.*;
import io.vertx.core.http.HttpHeaders;
import io.vertx.core.http.HttpServerOptions;
import io.vertx.core.http.impl.headers.HeadersMultiMap;
import io.vertx.core.internal.http.HttpHeadersInternal;

/**
* A request decoder using {@link HeadersMultiMap} which is faster than {@code DefaultHttpHeaders} used by the super class.
Expand All @@ -25,7 +25,7 @@ public VertxHttpRequestDecoder(HttpServerOptions options) {
options.getMaxInitialLineLength(),
options.getMaxHeaderSize(),
options.getMaxChunkSize(),
!HttpHeaders.DISABLE_HTTP_HEADERS_VALIDATION,
!HttpHeadersInternal.DISABLE_HTTP_HEADERS_VALIDATION,
options.getDecoderInitialBufferSize());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import io.netty.util.CharsetUtil;
import io.vertx.core.MultiMap;
import io.vertx.core.http.impl.HttpUtils;
import io.vertx.core.internal.http.HttpHeadersInternal;

import java.util.AbstractMap;
import java.util.Arrays;
Expand Down Expand Up @@ -60,7 +61,7 @@ private static CharSequence toValidCharSequence(Object value) {
static final BiConsumer<CharSequence, CharSequence> HTTP_VALIDATOR;

static {
if (!io.vertx.core.http.HttpHeaders.DISABLE_HTTP_HEADERS_VALIDATION) {
if (!HttpHeadersInternal.DISABLE_HTTP_HEADERS_VALIDATION) {
HTTP_VALIDATOR = HttpUtils::validateHeader;
} else {
HTTP_VALIDATOR = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import io.netty.handler.codec.http2.Http2Headers;
import io.vertx.core.MultiMap;
import io.vertx.core.http.impl.HttpUtils;
import io.vertx.core.internal.http.HttpHeadersInternal;

import java.util.AbstractList;
import java.util.Iterator;
Expand Down Expand Up @@ -93,7 +94,7 @@ public Set<String> names() {

@Override
public MultiMap add(String name, String value) {
if (!io.vertx.core.http.HttpHeaders.DISABLE_HTTP_HEADERS_VALIDATION) {
if (!HttpHeadersInternal.DISABLE_HTTP_HEADERS_VALIDATION) {
HttpUtils.validateHeader(name, value);
}
headers.add(HttpUtils.toLowerCase(name), value);
Expand All @@ -102,7 +103,7 @@ public MultiMap add(String name, String value) {

@Override
public MultiMap add(String name, Iterable<String> values) {
if (!io.vertx.core.http.HttpHeaders.DISABLE_HTTP_HEADERS_VALIDATION) {
if (!HttpHeadersInternal.DISABLE_HTTP_HEADERS_VALIDATION) {
HttpUtils.validateHeader(name, values);
}
headers.add(HttpUtils.toLowerCase(name), values);
Expand All @@ -127,7 +128,7 @@ public MultiMap addAll(Map<String, String> map) {

@Override
public MultiMap set(String name, String value) {
if (!io.vertx.core.http.HttpHeaders.DISABLE_HTTP_HEADERS_VALIDATION) {
if (!HttpHeadersInternal.DISABLE_HTTP_HEADERS_VALIDATION) {
HttpUtils.validateHeader(name, value);
}
name = (String) HttpUtils.toLowerCase(name);
Expand All @@ -141,7 +142,7 @@ public MultiMap set(String name, String value) {

@Override
public MultiMap set(String name, Iterable<String> values) {
if (!io.vertx.core.http.HttpHeaders.DISABLE_HTTP_HEADERS_VALIDATION) {
if (!HttpHeadersInternal.DISABLE_HTTP_HEADERS_VALIDATION) {
HttpUtils.validateHeader(name, values);
}
headers.set(HttpUtils.toLowerCase(name), values);
Expand Down Expand Up @@ -242,7 +243,7 @@ public boolean contains(CharSequence name, CharSequence value, boolean caseInsen

@Override
public MultiMap add(CharSequence name, CharSequence value) {
if (!io.vertx.core.http.HttpHeaders.DISABLE_HTTP_HEADERS_VALIDATION) {
if (!HttpHeadersInternal.DISABLE_HTTP_HEADERS_VALIDATION) {
HttpUtils.validateHeader(name, value);
}
headers.add(HttpUtils.toLowerCase(name), value);
Expand All @@ -251,7 +252,7 @@ public MultiMap add(CharSequence name, CharSequence value) {

@Override
public MultiMap add(CharSequence name, Iterable<CharSequence> values) {
if (!io.vertx.core.http.HttpHeaders.DISABLE_HTTP_HEADERS_VALIDATION) {
if (!HttpHeadersInternal.DISABLE_HTTP_HEADERS_VALIDATION) {
HttpUtils.validateHeader(name, values);
}
headers.add(HttpUtils.toLowerCase(name), values);
Expand All @@ -260,7 +261,7 @@ public MultiMap add(CharSequence name, Iterable<CharSequence> values) {

@Override
public MultiMap set(CharSequence name, CharSequence value) {
if (!io.vertx.core.http.HttpHeaders.DISABLE_HTTP_HEADERS_VALIDATION) {
if (!HttpHeadersInternal.DISABLE_HTTP_HEADERS_VALIDATION) {
HttpUtils.validateHeader(name, value);
}
name = HttpUtils.toLowerCase(name);
Expand All @@ -274,7 +275,7 @@ public MultiMap set(CharSequence name, CharSequence value) {

@Override
public MultiMap set(CharSequence name, Iterable<CharSequence> values) {
if (!io.vertx.core.http.HttpHeaders.DISABLE_HTTP_HEADERS_VALIDATION) {
if (!HttpHeadersInternal.DISABLE_HTTP_HEADERS_VALIDATION) {
HttpUtils.validateHeader(name, values);
}
headers.set(HttpUtils.toLowerCase(name), values);
Expand Down
4 changes: 3 additions & 1 deletion vertx-core/src/main/java/io/vertx/core/impl/SysProps.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
*/
package io.vertx.core.impl;

import io.vertx.core.internal.http.HttpHeadersInternal;

import java.io.File;

/**
Expand All @@ -20,7 +22,7 @@
public enum SysProps {

/**
* Duplicate of {@link io.vertx.core.http.HttpHeaders#DISABLE_HTTP_HEADERS_VALIDATION}
* Duplicate of {@link HttpHeadersInternal#DISABLE_HTTP_HEADERS_VALIDATION}
*/
DISABLE_HTTP_HEADERS_VALIDATION("vertx.disableHttpHeadersValidation"),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,21 @@
import io.vertx.core.http.HttpHeaders;
import io.vertx.core.http.impl.headers.HeadersAdaptor;
import io.vertx.core.http.impl.headers.Http2HeadersAdaptor;
import io.vertx.core.impl.SysProps;

/**
* HTTP multimap implementations.
*/
public interface HttpHeadersInternal extends HttpHeaders {

/** JVM system property that disables HTTP headers validation, don't use this in production. */
@Deprecated
String DISABLE_HTTP_HEADERS_VALIDATION_PROP_NAME = SysProps.DISABLE_HTTP_HEADERS_VALIDATION.name;

/** Constant that disables HTTP headers validation, this is a constant so the JIT can eliminate validation code. */
@Deprecated
boolean DISABLE_HTTP_HEADERS_VALIDATION = SysProps.DISABLE_HTTP_HEADERS_VALIDATION.getBoolean();

/**
* @return a multimap wrapping Netty HTTP {code header} instance
*/
Expand Down

0 comments on commit ff4646b

Please sign in to comment.