diff --git a/connectors/netty-connector/src/main/java/org/glassfish/jersey/netty/connector/Expect100ContinueConnectorExtension.java b/connectors/netty-connector/src/main/java/org/glassfish/jersey/netty/connector/Expect100ContinueConnectorExtension.java index 0c8bb4bb40a..471321ff063 100644 --- a/connectors/netty-connector/src/main/java/org/glassfish/jersey/netty/connector/Expect100ContinueConnectorExtension.java +++ b/connectors/netty-connector/src/main/java/org/glassfish/jersey/netty/connector/Expect100ContinueConnectorExtension.java @@ -47,7 +47,7 @@ public void invoke(ClientRequest request, HttpRequest extensionParam) { final boolean allowStreaming = length > expectContinueSizeThreshold || entityProcessing == RequestEntityProcessing.CHUNKED; - if (!extensionParam.protocolVersion().equals(HttpVersion.HTTP_1_1) + if (extensionParam.protocolVersion().equals(HttpVersion.HTTP_1_0) || !Boolean.TRUE.equals(expectContinueActivated) || !request.hasEntity() || !allowStreaming) { diff --git a/connectors/netty-connector/src/main/java/org/glassfish/jersey/netty/connector/JerseyExpectContinueHandler.java b/connectors/netty-connector/src/main/java/org/glassfish/jersey/netty/connector/JerseyExpectContinueHandler.java index d4ce1c029c7..5bb5873c901 100644 --- a/connectors/netty-connector/src/main/java/org/glassfish/jersey/netty/connector/JerseyExpectContinueHandler.java +++ b/connectors/netty-connector/src/main/java/org/glassfish/jersey/netty/connector/JerseyExpectContinueHandler.java @@ -81,7 +81,7 @@ CompletableFuture processExpect100ContinueRequest(HttpReques final ChannelFuture expect100ContinueFuture = (HttpUtil.is100ContinueExpected(nettyRequestHeaders)) // Send only head of the HTTP request enriched with Expect:100-continue header. - ? ch.writeAndFlush(nettyRequestHeaders).sync().awaitUninterruptibly() + ? ch.writeAndFlush(nettyRequestHeaders) // Expect:100-Continue either is not supported or is turned off : null; isExpected = expect100ContinueFuture != null; diff --git a/connectors/netty-connector/src/main/java/org/glassfish/jersey/netty/connector/NettyClientProperties.java b/connectors/netty-connector/src/main/java/org/glassfish/jersey/netty/connector/NettyClientProperties.java index 186c6d41597..50765a06080 100644 --- a/connectors/netty-connector/src/main/java/org/glassfish/jersey/netty/connector/NettyClientProperties.java +++ b/connectors/netty-connector/src/main/java/org/glassfish/jersey/netty/connector/NettyClientProperties.java @@ -82,4 +82,21 @@ public class NettyClientProperties { * @see org.glassfish.jersey.netty.connector.internal.RedirectException */ public static final String MAX_REDIRECTS = "jersey.config.client.NettyConnectorProvider.maxRedirects"; + + /** + * This timeout is used for waiting for 100-Continue response when 100-Continue is sent by the client. + * + * @since 2.41 + */ + public static final String + EXPECT_100_CONTINUE_TIMEOUT = "jersey.config.client.request.expect.100.continue.timeout"; + + /** + * The default value of EXPECT_100_CONTINUE_TIMEOUT. + * + * @since 2.41 + */ + public static final Integer + DEFAULT_EXPECT_100_CONTINUE_TIMEOUT_VALUE = 500; + } diff --git a/connectors/netty-connector/src/main/java/org/glassfish/jersey/netty/connector/NettyConnector.java b/connectors/netty-connector/src/main/java/org/glassfish/jersey/netty/connector/NettyConnector.java index 20211c95f0a..556eaae08c8 100644 --- a/connectors/netty-connector/src/main/java/org/glassfish/jersey/netty/connector/NettyConnector.java +++ b/connectors/netty-connector/src/main/java/org/glassfish/jersey/netty/connector/NettyConnector.java @@ -193,7 +193,8 @@ protected void execute(final ClientRequest jerseyRequest, final Set redirec final CompletableFuture responseAvailable) { Integer timeout = jerseyRequest.resolveProperty(ClientProperties.READ_TIMEOUT, 0); final Integer expect100ContinueTimeout = jerseyRequest.resolveProperty( - ClientProperties.EXPECT_100_CONTINUE_TIMEOUT, ClientProperties.EXPECT_100_CONTINUE_TIMEOUT_VALUE); + NettyClientProperties.EXPECT_100_CONTINUE_TIMEOUT, + NettyClientProperties.DEFAULT_EXPECT_100_CONTINUE_TIMEOUT_VALUE); if (timeout == null || timeout < 0) { throw new ProcessingException(LocalizationMessages.WRONG_READ_TIMEOUT(timeout)); } diff --git a/core-client/src/main/java/org/glassfish/jersey/client/ClientProperties.java b/core-client/src/main/java/org/glassfish/jersey/client/ClientProperties.java index 95a0a3eba07..7ba912a1d02 100644 --- a/core-client/src/main/java/org/glassfish/jersey/client/ClientProperties.java +++ b/core-client/src/main/java/org/glassfish/jersey/client/ClientProperties.java @@ -454,22 +454,6 @@ public final class ClientProperties { */ public static final Long DEFAULT_EXPECT_100_CONTINUE_THRESHOLD_SIZE = 65536L; - /** - * Property of timeout setting which shall be waited before request processing without any expectation - * - * @since 2.41 - */ - public static final String - EXPECT_100_CONTINUE_TIMEOUT = "jersey.config.client.request.expect.100.continue.timeout"; - - /** - * Default value of timeout which shall be waited before request processing without any expectation - * - * @since 2.41 - */ - public static final Integer - EXPECT_100_CONTINUE_TIMEOUT_VALUE = 500; - /** * The property defines the desired format of query parameters. * diff --git a/docs/src/main/docbook/appendix-properties.xml b/docs/src/main/docbook/appendix-properties.xml index 7ac03f357d0..87227fbc307 100644 --- a/docs/src/main/docbook/appendix-properties.xml +++ b/docs/src/main/docbook/appendix-properties.xml @@ -947,18 +947,6 @@ - - &jersey.client.ClientProperties.EXPECT_100_CONTINUE_TIMEOUT; - jersey.config.client.request.expect.100.continue.timeout - - - Property for expect:100-continue timeout value which shall be waited until the full - request is sent ignoring Expect:100-continue feature. - Default timeout value is (500 ms) after which Expect:100-Continue feature is ignored. - Since 2.41 - - - &jersey.client.ClientProperties.FEATURE_AUTO_DISCOVERY_DISABLE; jersey.config.client.disableAutoDiscovery @@ -2048,6 +2036,18 @@ + + &jersey.netty.NettyClientProperties.EXPECT_100_CONTINUE_TIMEOUT; + jersey.config.client.request.expect.100.continue.timeout + + + Property for expect:100-continue timeout value which shall be waited until the full + request is sent ignoring Expect:100-continue feature. + Default timeout value is (500 ms) after which Expect:100-Continue feature is ignored. + Since 2.41 + + + diff --git a/docs/src/main/docbook/jersey.ent b/docs/src/main/docbook/jersey.ent index 89cb5549566..955046dc102 100644 --- a/docs/src/main/docbook/jersey.ent +++ b/docs/src/main/docbook/jersey.ent @@ -356,7 +356,6 @@ ClientProperties.DIGESTAUTH_URI_CACHE_SIZELIMIT" > ClientProperties.EXPECT_100_CONTINUE" > ClientProperties.EXPECT_100_CONTINUE_THRESHOLD_SIZE" > -ClientProperties.EXPECT_100_CONTINUE_TIMEOUT" > ClientLifecycleListener"> Connector"> ConnectorProvider"> @@ -557,6 +556,7 @@ NettyClientProperties.MAX_CONNECTIONS" > NettyClientProperties.MAX_CONNECTIONS_TOTAL" > NettyClientProperties.MAX_REDIRECTS" > +NettyClientProperties.EXPECT_100_CONTINUE_TIMEOUT" > NettyConnectorProvider"> ApplicationHandler"> @BackgroundScheduler"> diff --git a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/nettyconnector/Expect100ContinueTest.java b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/nettyconnector/Expect100ContinueTest.java index 0e22557fc72..bcb350d16d2 100644 --- a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/nettyconnector/Expect100ContinueTest.java +++ b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/nettyconnector/Expect100ContinueTest.java @@ -23,6 +23,7 @@ import org.glassfish.jersey.client.ClientProperties; import org.glassfish.jersey.client.RequestEntityProcessing; import org.glassfish.jersey.client.http.Expect100ContinueFeature; +import org.glassfish.jersey.netty.connector.NettyClientProperties; import org.glassfish.jersey.netty.connector.NettyConnectorProvider; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; @@ -176,7 +177,7 @@ public void testExpect100ContinueUnauthorized() { assertThrows(ProcessingException.class, () -> target(RESOURCE_PATH_UNAUTHORIZED) .property(ClientProperties.EXPECT_100_CONTINUE_THRESHOLD_SIZE, 43L) .property(ClientProperties.EXPECT_100_CONTINUE, Boolean.TRUE) - .property(ClientProperties.EXPECT_100_CONTINUE_TIMEOUT, 10000) + .property(NettyClientProperties.EXPECT_100_CONTINUE_TIMEOUT, 10000) .request().header(HttpHeaders.CONTENT_LENGTH, 44L) .post(Entity.text(ENTITY_STRING))); } @@ -186,7 +187,7 @@ public void testExpect100ContinuePayloadTooLarge() { assertThrows(ProcessingException.class, () -> target(RESOURCE_PATH_PAYLOAD_TOO_LARGE) .property(ClientProperties.EXPECT_100_CONTINUE_THRESHOLD_SIZE, 43L) .property(ClientProperties.EXPECT_100_CONTINUE, Boolean.TRUE) - .property(ClientProperties.EXPECT_100_CONTINUE_TIMEOUT, 10000) + .property(NettyClientProperties.EXPECT_100_CONTINUE_TIMEOUT, 10000) .request().header(HttpHeaders.CONTENT_LENGTH, 44L) .post(Entity.text(ENTITY_STRING))); } @@ -196,7 +197,7 @@ public void testExpect100ContinueMethodNotSupported() { assertThrows(ProcessingException.class, () -> target(RESOURCE_PATH_METHOD_NOT_SUPPORTED) .property(ClientProperties.EXPECT_100_CONTINUE_THRESHOLD_SIZE, 43L) .property(ClientProperties.EXPECT_100_CONTINUE, Boolean.TRUE) - .property(ClientProperties.EXPECT_100_CONTINUE_TIMEOUT, 10000) + .property(NettyClientProperties.EXPECT_100_CONTINUE_TIMEOUT, 10000) .request().header(HttpHeaders.CONTENT_LENGTH, 44L) .post(Entity.text(ENTITY_STRING))); } diff --git a/tests/integration/jackson-14/pom.xml b/tests/integration/jackson-14/pom.xml index a07de08b534..04a31ce8de7 100644 --- a/tests/integration/jackson-14/pom.xml +++ b/tests/integration/jackson-14/pom.xml @@ -112,11 +112,6 @@ hamcrest test - - org.junit.jupiter - junit-jupiter - test - - + \ No newline at end of file