formpost() — netty Function Reference
Architecture documentation for the formpost() function in HttpUploadClient.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 74523085_3ff4_6038_bdc0_b90d4585970b["formpost()"] b9da3ba5_7453_22c6_2d8f_69c79b4ca314["HttpUploadClient"] 74523085_3ff4_6038_bdc0_b90d4585970b -->|defined in| b9da3ba5_7453_22c6_2d8f_69c79b4ca314 9eb10f57_11e0_77d4_dfe6_470ff611d081["main()"] 9eb10f57_11e0_77d4_dfe6_470ff611d081 -->|calls| 74523085_3ff4_6038_bdc0_b90d4585970b d9705f9a_6272_0aa0_3cd7_4bfaf6636ab5["formpostmultipart()"] d9705f9a_6272_0aa0_3cd7_4bfaf6636ab5 -->|calls| 74523085_3ff4_6038_bdc0_b90d4585970b style 74523085_3ff4_6038_bdc0_b90d4585970b fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
example/src/main/java/io/netty/example/http/upload/HttpUploadClient.java lines 207–263
private static List<InterfaceHttpData> formpost(
Bootstrap bootstrap,
String host, int port, URI uriSimple, File file, HttpDataFactory factory,
List<Entry<String, String>> headers) throws Exception {
// XXX /formpost
// Start the connection attempt.
ChannelFuture future = bootstrap.connect(SocketUtils.socketAddress(host, port));
// Wait until the connection attempt succeeds or fails.
Channel channel = future.sync().channel();
// Prepare the HTTP request.
HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, uriSimple.toASCIIString());
// Use the PostBody encoder
HttpPostRequestEncoder bodyRequestEncoder =
new HttpPostRequestEncoder(factory, request, false); // false => not multipart
// it is legal to add directly header or cookie into the request until finalize
for (Entry<String, String> entry : headers) {
request.headers().set(entry.getKey(), entry.getValue());
}
// add Form attribute
bodyRequestEncoder.addBodyAttribute("getform", "POST");
bodyRequestEncoder.addBodyAttribute("info", "first value");
bodyRequestEncoder.addBodyAttribute("secondinfo", "secondvalue ���&");
bodyRequestEncoder.addBodyAttribute("thirdinfo", textArea);
bodyRequestEncoder.addBodyAttribute("fourthinfo", textAreaLong);
bodyRequestEncoder.addBodyFileUpload("myfile", file, "application/x-zip-compressed", false);
// finalize request
request = bodyRequestEncoder.finalizeRequest();
// Create the bodylist to be reused on the last version with Multipart support
List<InterfaceHttpData> bodylist = bodyRequestEncoder.getBodyListAttributes();
// send request
channel.write(request);
// test if request was chunked and if so, finish the write
if (bodyRequestEncoder.isChunked()) { // could do either request.isChunked()
// either do it through ChunkedWriteHandler
channel.write(bodyRequestEncoder);
}
channel.flush();
// Do not clear here since we will reuse the InterfaceHttpData on the next request
// for the example (limit action on client side). Take this as a broadcast of the same
// request on both Post actions.
//
// On standard program, it is clearly recommended to clean all files after each request
// bodyRequestEncoder.cleanFiles();
// Wait for the server to close the connection.
channel.closeFuture().sync();
return bodylist;
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does formpost() do?
formpost() is a function in the netty codebase, defined in example/src/main/java/io/netty/example/http/upload/HttpUploadClient.java.
Where is formpost() defined?
formpost() is defined in example/src/main/java/io/netty/example/http/upload/HttpUploadClient.java at line 207.
What calls formpost()?
formpost() is called by 2 function(s): formpostmultipart, main.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free