Skip to content

Commit

Permalink
Improved handling of early response messages by the classic client pr…
Browse files Browse the repository at this point in the history
…otocol handler (corrections)
  • Loading branch information
ok2c committed May 26, 2020
1 parent e64bab5 commit 39f6d69
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
public class HttpRequestExecutor {

public static final Timeout DEFAULT_WAIT_FOR_CONTINUE = Timeout.ofSeconds(3);
public static final Timeout DEFAULT_WAIT_FOR_EARLY_RESPONSE = Timeout.ofMilliseconds(5);
public static final Timeout DEFAULT_WAIT_FOR_EARLY_RESPONSE = Timeout.ofMilliseconds(50);
public static final long LARGE_MESSAGE_LEN = 64 * 1024;

private final Timeout waitForContinue;
Expand Down Expand Up @@ -162,7 +162,11 @@ public ClassicHttpResponse execute(
final Header expect = request.getFirstHeader(HttpHeaders.EXPECT);
expectContinue = expect != null && HeaderElements.CONTINUE.equalsIgnoreCase(expect.getValue());
if (!expectContinue) {
if (entity.getContentLength() > LARGE_MESSAGE_LEN && conn.isDataAvailable(waitForEarlyResponse)) {
final boolean largeEntity = entity.getContentLength() > LARGE_MESSAGE_LEN;
if (largeEntity) {
conn.flush();
}
if (largeEntity && conn.isDataAvailable(waitForEarlyResponse)) {
conn.terminateRequest(request);
} else {
conn.sendRequestEntity(request);
Expand Down

0 comments on commit 39f6d69

Please sign in to comment.