HttpRequest() — netty Function Reference
Architecture documentation for the HttpRequest() function in HttpPostRequestEncoder.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 759866ff_a8ab_daf9_32b8_f22d083766c6["HttpRequest()"] 1f646438_907e_54fe_bc9e_a9535d782cc8["HttpPostRequestEncoder"] 759866ff_a8ab_daf9_32b8_f22d083766c6 -->|defined in| 1f646438_907e_54fe_bc9e_a9535d782cc8 156929ac_dd34_b8ae_7579_14a87e4c6842["ErrorDataEncoderException()"] 759866ff_a8ab_daf9_32b8_f22d083766c6 -->|calls| 156929ac_dd34_b8ae_7579_14a87e4c6842 408f253d_b5e0_74d6_900a_2bcebda5046e["WrappedHttpRequest()"] 759866ff_a8ab_daf9_32b8_f22d083766c6 -->|calls| 408f253d_b5e0_74d6_900a_2bcebda5046e ea389be0_e79b_c01e_c5f5_1f0be07a1df8["release()"] 759866ff_a8ab_daf9_32b8_f22d083766c6 -->|calls| ea389be0_e79b_c01e_c5f5_1f0be07a1df8 b6d6cf82_4a8b_723c_b12f_34123d470908["WrappedFullHttpRequest()"] 759866ff_a8ab_daf9_32b8_f22d083766c6 -->|calls| b6d6cf82_4a8b_723c_b12f_34123d470908 style 759866ff_a8ab_daf9_32b8_f22d083766c6 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpPostRequestEncoder.java lines 729–812
public HttpRequest finalizeRequest() throws ErrorDataEncoderException {
// Finalize the multipartHttpDatas
if (!headerFinalized) {
if (isMultipart) {
InternalAttribute internal = new InternalAttribute(charset);
if (duringMixedMode) {
internal.addValue("\r\n--" + multipartMixedBoundary + "--");
}
internal.addValue("\r\n--" + multipartDataBoundary + "--\r\n");
multipartHttpDatas.add(internal);
multipartMixedBoundary = null;
currentFileUpload = null;
duringMixedMode = false;
globalBodySize += internal.size();
}
headerFinalized = true;
} else {
throw new ErrorDataEncoderException("Header already encoded");
}
HttpHeaders headers = request.headers();
List<String> contentTypes = headers.getAll(HttpHeaderNames.CONTENT_TYPE);
List<String> transferEncoding = headers.getAll(HttpHeaderNames.TRANSFER_ENCODING);
if (contentTypes != null) {
headers.remove(HttpHeaderNames.CONTENT_TYPE);
for (String contentType : contentTypes) {
// "multipart/form-data; boundary=--89421926422648"
String lowercased = contentType.toLowerCase();
if (lowercased.startsWith(HttpHeaderValues.MULTIPART_FORM_DATA.toString()) ||
lowercased.startsWith(HttpHeaderValues.APPLICATION_X_WWW_FORM_URLENCODED.toString())) {
// ignore
} else {
headers.add(HttpHeaderNames.CONTENT_TYPE, contentType);
}
}
}
if (isMultipart) {
String value = HttpHeaderValues.MULTIPART_FORM_DATA + "; " + HttpHeaderValues.BOUNDARY + '='
+ multipartDataBoundary;
headers.add(HttpHeaderNames.CONTENT_TYPE, value);
} else {
// Not multipart
headers.add(HttpHeaderNames.CONTENT_TYPE, HttpHeaderValues.APPLICATION_X_WWW_FORM_URLENCODED);
}
// Now consider size for chunk or not
long realSize = globalBodySize;
if (!isMultipart) {
realSize -= 1; // last '&' removed
}
iterator = multipartHttpDatas.listIterator();
headers.set(HttpHeaderNames.CONTENT_LENGTH, String.valueOf(realSize));
if (realSize > HttpPostBodyUtil.chunkSize || isMultipart) {
isChunked = true;
if (transferEncoding != null) {
headers.remove(HttpHeaderNames.TRANSFER_ENCODING);
for (CharSequence v : transferEncoding) {
if (HttpHeaderValues.CHUNKED.contentEqualsIgnoreCase(v)) {
// ignore
} else {
headers.add(HttpHeaderNames.TRANSFER_ENCODING, v);
}
}
}
HttpUtil.setTransferEncodingChunked(request, true);
// wrap to hide the possible content
return new WrappedHttpRequest(request);
} else {
// get the only one body and set it to the request
HttpContent chunk = nextChunk();
if (request instanceof FullHttpRequest) {
FullHttpRequest fullRequest = (FullHttpRequest) request;
ByteBuf chunkContent = chunk.content();
if (fullRequest.content() != chunkContent) {
fullRequest.content().clear().writeBytes(chunkContent);
chunkContent.release();
}
return fullRequest;
} else {
return new WrappedFullHttpRequest(request, chunk);
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does HttpRequest() do?
HttpRequest() is a function in the netty codebase, defined in codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpPostRequestEncoder.java.
Where is HttpRequest() defined?
HttpRequest() is defined in codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpPostRequestEncoder.java at line 729.
What does HttpRequest() call?
HttpRequest() calls 4 function(s): ErrorDataEncoderException, WrappedFullHttpRequest, WrappedHttpRequest, release.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free