Skip to content

Commit 791cc67

Browse files
committed
HTTPCORE-796: abort redirected requests during the expect-continue handshake the same way as errors
1 parent d96a00f commit 791cc67

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/HttpRequestExecutor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ public ClassicHttpResponse execute(
183183
}
184184
response = null;
185185
continue;
186-
} else if (status >= HttpStatus.SC_CLIENT_ERROR) {
186+
} else if (status >= HttpStatus.SC_REDIRECTION) {
187187
conn.terminateRequest(request);
188188
} else {
189189
conn.sendRequestEntity(request);

httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ClientHttp1StreamHandler.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,14 @@ void consumeHeader(final HttpResponse response, final EntityDetails entityDetail
230230
keepAlive = false;
231231
}
232232
}
233+
boolean abort = false;
233234
if (requestState.get() == MessageState.ACK) {
234235
if (status == HttpStatus.SC_CONTINUE || status >= HttpStatus.SC_SUCCESS) {
235236
outputChannel.setSocketTimeout(timeout);
236237
requestState.set(MessageState.BODY);
237-
if (status < HttpStatus.SC_CLIENT_ERROR) {
238+
if (status >= HttpStatus.SC_REDIRECTION) {
239+
abort = true;
240+
} else {
238241
exchangeHandler.produce(internalDataChannel);
239242
}
240243
}
@@ -243,7 +246,7 @@ void consumeHeader(final HttpResponse response, final EntityDetails entityDetail
243246
return;
244247
}
245248
if (requestState.get() == MessageState.BODY) {
246-
if (status >= HttpStatus.SC_CLIENT_ERROR) {
249+
if (abort || status >= HttpStatus.SC_CLIENT_ERROR) {
247250
requestState.set(MessageState.COMPLETE);
248251
if (!outputChannel.abortGracefully()) {
249252
keepAlive = false;

0 commit comments

Comments
 (0)