Skip to content

Commit

Permalink
Create on demand the response object for "Expect: 100-continue" (#3362)
Browse files Browse the repository at this point in the history
  • Loading branch information
violetagg committed Jul 22, 2024
1 parent e70defc commit bbf0131
Showing 1 changed file with 8 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011-2023 VMware, Inc. or its affiliates, All Rights Reserved.
* Copyright (c) 2011-2024 VMware, Inc. or its affiliates, All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -45,7 +45,6 @@
import io.netty.handler.codec.http.DefaultHttpResponse;
import io.netty.handler.codec.http.DefaultLastHttpContent;
import io.netty.handler.codec.http.FullHttpRequest;
import io.netty.handler.codec.http.FullHttpResponse;
import io.netty.handler.codec.http.HttpContent;
import io.netty.handler.codec.http.HttpHeaderNames;
import io.netty.handler.codec.http.HttpHeaderValues;
Expand Down Expand Up @@ -411,13 +410,13 @@ public Flux<?> receiveObject() {
// If decoding a response, just throw an error.
if (is100ContinueExpected) {
return FutureMono.deferFuture(() -> {
if (!hasSentHeaders()) {
return channel().writeAndFlush(CONTINUE);
}
return channel().newSucceededFuture();
})

.thenMany(super.receiveObject());
if (!hasSentHeaders()) {
return channel().writeAndFlush(
new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.CONTINUE, EMPTY_BUFFER));
}
return channel().newSucceededFuture();
})
.thenMany(super.receiveObject());
}
else {
return super.receiveObject();
Expand Down Expand Up @@ -1009,11 +1008,6 @@ public Context currentContext() {

static final BiPredicate<HttpServerRequest, HttpServerResponse> COMPRESSION_DISABLED = (req, res) -> false;

static final FullHttpResponse CONTINUE =
new DefaultFullHttpResponse(HttpVersion.HTTP_1_1,
HttpResponseStatus.CONTINUE,
EMPTY_BUFFER);

static final class FailedHttpServerRequest extends HttpServerOperations {

final HttpResponse customResponse;
Expand Down

0 comments on commit bbf0131

Please sign in to comment.