Skip to content

Commit 4059de5

Browse files
committed
Fix the issue where putobject requests sometimes is hanging because 100 continue response is not being read automatically
1 parent d314a0d commit 4059de5

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"category": "Netty NIO Async HTTP Client",
3+
"type": "bugfix",
4+
"description": "Fix the issue where streaming requests with `Expect: 100-continue` header sometimes are hanging because 100Continue response message is not being read automatically. See [#459](https://github.com/aws/aws-sdk-java-v2/issues/459)"
5+
}

http-clients/netty-nio-client/src/main/java/software/amazon/awssdk/http/nio/netty/internal/NettyRequestExecutor.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,29 @@ private void writeRequest(HttpRequest request) {
182182
}
183183
});
184184

185-
// FullDuplex calls need to start reading at the same time we make the request.
186-
if (context.executeRequest().fullDuplex()) {
185+
if (shouldExplicitlyTriggerRead()) {
187186
channel.pipeline().addFirst(new ReadTimeoutHandler(context.configuration().readTimeoutMillis(),
188187
TimeUnit.MILLISECONDS));
189188
channel.read();
190189
}
191190
}
192191

192+
/**
193+
* It should explicitly trigger Read for the following situations:
194+
*
195+
* - FullDuplex calls need to start reading at the same time we make the request.
196+
* - Request with "Expect: 100-continue" header should read the 100 continue response.
197+
*
198+
* @return true if it should explicitly read from channel
199+
*/
200+
private boolean shouldExplicitlyTriggerRead() {
201+
boolean is100ContinueExpected = context.executeRequest().request()
202+
.firstMatchingHeader("Expect")
203+
.filter(b -> b.equalsIgnoreCase("100-continue")).isPresent();
204+
205+
return context.executeRequest().fullDuplex() || is100ContinueExpected;
206+
}
207+
193208
private URI endpoint() {
194209
return context.executeRequest().request().getUri();
195210
}

0 commit comments

Comments
 (0)