-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Move HTTP content aggregation from Netty into RestController #129302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
0cd4f72
d994791
7460a07
3abd181
c7bb930
2077ad4
43bf06a
5797b76
db645ed
c88dbbe
59c0e23
7fcf9bb
737fb67
d2e1622
86b8e28
34e8881
cdc8560
5dfbd9f
43232ee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| pr: 129302 | ||
| summary: Move HTTP content aggregation from Netty into `RestController` | ||
| area: Network | ||
| type: enhancement | ||
| issues: [] |
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -9,13 +9,11 @@ | |||||
|
|
||||||
| package org.elasticsearch.http.netty4; | ||||||
|
|
||||||
| import io.netty.buffer.Unpooled; | ||||||
| import io.netty.handler.codec.http.DefaultFullHttpRequest; | ||||||
| import io.netty.handler.codec.http.EmptyHttpHeaders; | ||||||
| import io.netty.handler.codec.http.FullHttpRequest; | ||||||
| import io.netty.handler.codec.http.DefaultHttpRequest; | ||||||
| import io.netty.handler.codec.http.HttpHeaderNames; | ||||||
| import io.netty.handler.codec.http.HttpHeaders; | ||||||
| import io.netty.handler.codec.http.HttpMethod; | ||||||
| import io.netty.handler.codec.http.HttpUtil; | ||||||
| import io.netty.handler.codec.http.QueryStringDecoder; | ||||||
| import io.netty.handler.codec.http.cookie.Cookie; | ||||||
| import io.netty.handler.codec.http.cookie.ServerCookieDecoder; | ||||||
|
|
@@ -28,7 +26,6 @@ | |||||
| import org.elasticsearch.rest.ChunkedRestResponseBodyPart; | ||||||
| import org.elasticsearch.rest.RestRequest; | ||||||
| import org.elasticsearch.rest.RestStatus; | ||||||
| import org.elasticsearch.transport.netty4.Netty4Utils; | ||||||
|
|
||||||
| import java.util.AbstractMap; | ||||||
| import java.util.Collection; | ||||||
|
|
@@ -41,71 +38,46 @@ | |||||
|
|
||||||
| public class Netty4HttpRequest implements HttpRequest { | ||||||
|
|
||||||
| private final FullHttpRequest request; | ||||||
| private final HttpBody content; | ||||||
| private final int sequence; | ||||||
| private final io.netty.handler.codec.http.HttpRequest nettyRequest; | ||||||
| private HttpBody content; | ||||||
| private final Map<String, List<String>> headers; | ||||||
| private final AtomicBoolean released; | ||||||
| private final Exception inboundException; | ||||||
| private final boolean pooled; | ||||||
| private final int sequence; | ||||||
| private final QueryStringDecoder queryStringDecoder; | ||||||
|
|
||||||
| Netty4HttpRequest(int sequence, io.netty.handler.codec.http.HttpRequest request, Netty4HttpRequestBodyStream contentStream) { | ||||||
| this( | ||||||
| sequence, | ||||||
| new DefaultFullHttpRequest( | ||||||
| request.protocolVersion(), | ||||||
| request.method(), | ||||||
| request.uri(), | ||||||
| Unpooled.EMPTY_BUFFER, | ||||||
| request.headers(), | ||||||
| EmptyHttpHeaders.INSTANCE | ||||||
| ), | ||||||
| new AtomicBoolean(false), | ||||||
| true, | ||||||
| contentStream, | ||||||
| null | ||||||
| ); | ||||||
| } | ||||||
|
|
||||||
| Netty4HttpRequest(int sequence, FullHttpRequest request) { | ||||||
| this(sequence, request, new AtomicBoolean(false), true, Netty4Utils.fullHttpBodyFrom(request.content())); | ||||||
| } | ||||||
|
|
||||||
| Netty4HttpRequest(int sequence, FullHttpRequest request, Exception inboundException) { | ||||||
| this(sequence, request, new AtomicBoolean(false), true, Netty4Utils.fullHttpBodyFrom(request.content()), inboundException); | ||||||
| public Netty4HttpRequest(int sequence, io.netty.handler.codec.http.HttpRequest nettyRequest, Exception exception) { | ||||||
| this(sequence, nettyRequest, HttpBody.empty(), new AtomicBoolean(false), exception); | ||||||
| } | ||||||
|
|
||||||
| private Netty4HttpRequest(int sequence, FullHttpRequest request, AtomicBoolean released, boolean pooled, HttpBody content) { | ||||||
| this(sequence, request, released, pooled, content, null); | ||||||
| public Netty4HttpRequest(int sequence, io.netty.handler.codec.http.HttpRequest nettyRequest, HttpBody content) { | ||||||
| this(sequence, nettyRequest, content, new AtomicBoolean(false), null); | ||||||
| } | ||||||
|
|
||||||
| private Netty4HttpRequest( | ||||||
| public Netty4HttpRequest( | ||||||
|
||||||
| public Netty4HttpRequest( | |
| private Netty4HttpRequest( |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we assert that we only ever replace a streaming body with a fully-aggregated body?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing mutability for the HTTP request body, I need to swap stream with full content after aggregation. References to original HTTP request spread roots too deep.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
readability nit: this has to happen before the
ctx::readabove; of course it does today because we're already on the event loop so the dispatchedctx::readhappens after this method returns but still it's confusing to write them in this order.