Skip to content

Commit

Permalink
Expect:100-continue fixes for Nett
Browse files Browse the repository at this point in the history
Signed-off-by: Maxim Nesen <maxim.nesen@oracle.com>
  • Loading branch information
senivam committed Oct 9, 2023
1 parent 61ab565 commit 97a2ec2
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ CompletableFuture<HttpResponseStatus> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

}
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ protected void execute(final ClientRequest jerseyRequest, final Set<URI> redirec
final CompletableFuture<ClientResponse> 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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
24 changes: 12 additions & 12 deletions docs/src/main/docbook/appendix-properties.xml
Original file line number Diff line number Diff line change
Expand Up @@ -947,18 +947,6 @@
</para>
</entry>
</row>
<row>
<entry>&jersey.client.ClientProperties.EXPECT_100_CONTINUE_TIMEOUT;</entry>
<entry><literal>jersey.config.client.request.expect.100.continue.timeout</literal></entry>
<entry>
<para>
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.
<literal>Since 2.41</literal>
</para>
</entry>
</row>
<row>
<entry>&jersey.client.ClientProperties.FEATURE_AUTO_DISCOVERY_DISABLE;</entry>
<entry><literal>jersey.config.client.disableAutoDiscovery</literal></entry>
Expand Down Expand Up @@ -2048,6 +2036,18 @@
</para>
</entry>
</row>
<row>
<entry>&jersey.netty.NettyClientProperties.EXPECT_100_CONTINUE_TIMEOUT;</entry>
<entry><literal>jersey.config.client.request.expect.100.continue.timeout</literal></entry>
<entry>
<para>
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.
<literal>Since 2.41</literal>
</para>
</entry>
</row>
</tbody>
</tgroup>
</table>
Expand Down
2 changes: 1 addition & 1 deletion docs/src/main/docbook/jersey.ent
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,6 @@
<!ENTITY jersey.client.ClientProperties.DIGESTAUTH_URI_CACHE_SIZELIMIT "<link xlink:href='&jersey.javadoc.uri.prefix;/client/ClientProperties.html#DIGESTAUTH_URI_CACHE_SIZELIMIT'>ClientProperties.DIGESTAUTH_URI_CACHE_SIZELIMIT</link>" >
<!ENTITY jersey.client.ClientProperties.EXPECT_100_CONTINUE "<link xlink:href='&jersey.javadoc.uri.prefix;/client/ClientProperties.html#EXPECT_100_CONTINUE'>ClientProperties.EXPECT_100_CONTINUE</link>" >
<!ENTITY jersey.client.ClientProperties.EXPECT_100_CONTINUE_THRESHOLD_SIZE "<link xlink:href='&jersey.javadoc.uri.prefix;/client/ClientProperties.html#EXPECT_100_CONTINUE_THRESHOLD_SIZE'>ClientProperties.EXPECT_100_CONTINUE_THRESHOLD_SIZE</link>" >
<!ENTITY jersey.client.ClientProperties.EXPECT_100_CONTINUE_TIMEOUT "<link xlink:href='&jersey.javadoc.uri.prefix;/client/ClientProperties.html#EXPECT_100_CONTINUE_TIMEOUT'>ClientProperties.EXPECT_100_CONTINUE_TIMEOUT</link>" >
<!ENTITY jersey.client.ClientLifecycleListener "<link xlink:href='&jersey.javadoc.uri.prefix;/client/ClientLifecycleListener.html'>ClientLifecycleListener</link>">
<!ENTITY jersey.client.Connector "<link xlink:href='&jersey.javadoc.uri.prefix;/client/spi/Connector.html'>Connector</link>">
<!ENTITY jersey.client.ConnectorProvider "<link xlink:href='&jersey.javadoc.uri.prefix;/client/spi/ConnectorProvider.html'>ConnectorProvider</link>">
Expand Down Expand Up @@ -557,6 +556,7 @@
<!ENTITY jersey.netty.NettyClientProperties.MAX_CONNECTIONS "<link xlink:href='&jersey.javadoc.uri.prefix;/netty/connector/NettyClientProperties.html#MAX_CONNECTIONS'>NettyClientProperties.MAX_CONNECTIONS</link>" >
<!ENTITY jersey.netty.NettyClientProperties.MAX_CONNECTIONS_TOTAL "<link xlink:href='&jersey.javadoc.uri.prefix;/netty/connector/NettyClientProperties.html#MAX_CONNECTIONS_TOTAL'>NettyClientProperties.MAX_CONNECTIONS_TOTAL</link>" >
<!ENTITY jersey.netty.NettyClientProperties.MAX_REDIRECTS "<link xlink:href='&jersey.javadoc.uri.prefix;/netty/connector/NettyClientProperties.html#MAX_REDIRECTS'>NettyClientProperties.MAX_REDIRECTS</link>" >
<!ENTITY jersey.netty.NettyClientProperties.EXPECT_100_CONTINUE_TIMEOUT "<link xlink:href='&jersey.javadoc.uri.prefix;/netty/connector/NettyClientProperties.html#EXPECT_100_CONTINUE_TIMEOUT'>NettyClientProperties.EXPECT_100_CONTINUE_TIMEOUT</link>" >
<!ENTITY jersey.netty.NettyConnectorProvider "<link xlink:href='&jersey.javadoc.uri.prefix;/netty/connector/NettyConnectorProvider.html'>NettyConnectorProvider</link>">
<!ENTITY jersey.server.ApplicationHandler "<link xlink:href='&jersey.javadoc.uri.prefix;/server/ApplicationHandler.html'>ApplicationHandler</link>">
<!ENTITY jersey.server.BackgroundScheduler "<link xlink:href='&jersey.javadoc.uri.prefix;/server/BackgroundScheduler.html'>@BackgroundScheduler</link>">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)));
}
Expand All @@ -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)));
}
Expand All @@ -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)));
}
Expand Down
7 changes: 1 addition & 6 deletions tests/integration/jackson-14/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,6 @@
<artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

</project>
</project>

0 comments on commit 97a2ec2

Please sign in to comment.