Fix for ssl example
This commit is contained in:
parent
c370fab6fb
commit
a78318149e
@ -124,6 +124,7 @@ public class HttpUploadClient {
|
|||||||
DiskAttribute.baseDirectory = null; // system temp directory
|
DiskAttribute.baseDirectory = null; // system temp directory
|
||||||
|
|
||||||
// Simple Get form: no factory used (not usable)
|
// Simple Get form: no factory used (not usable)
|
||||||
|
System.err.println("==========================================\nStarting Get\n==========================================");
|
||||||
List<Entry<String, String>> headers =
|
List<Entry<String, String>> headers =
|
||||||
formget(bootstrap, host, port, get, uriSimple);
|
formget(bootstrap, host, port, get, uriSimple);
|
||||||
if (headers == null) {
|
if (headers == null) {
|
||||||
@ -131,6 +132,7 @@ public class HttpUploadClient {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Simple Post form: factory used for big attributes
|
// Simple Post form: factory used for big attributes
|
||||||
|
System.err.println("==========================================\nStarting Simple Post\n==========================================");
|
||||||
List<InterfaceHttpData> bodylist =
|
List<InterfaceHttpData> bodylist =
|
||||||
formpost(bootstrap, host, port, uriSimple, file, factory, headers);
|
formpost(bootstrap, host, port, uriSimple, file, factory, headers);
|
||||||
if (bodylist == null) {
|
if (bodylist == null) {
|
||||||
@ -138,7 +140,10 @@ public class HttpUploadClient {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Multipart Post form: factory used
|
// Multipart Post form: factory used
|
||||||
formpostmultipart(bootstrap, host, port, uriFile, factory, headers, bodylist);
|
System.err.println("==========================================\nStarting PostUpload with no force chunk\n==========================================");
|
||||||
|
formpostmultipart(bootstrap, host, port, uriFile, factory, headers, bodylist, false);
|
||||||
|
System.err.println("==========================================\nStarting PostUpload with force chunk\n==========================================");
|
||||||
|
formpostmultipart(bootstrap, host, port, uriFile, factory, headers, bodylist, true);
|
||||||
|
|
||||||
// Shut down executor threads to exit.
|
// Shut down executor threads to exit.
|
||||||
bootstrap.releaseExternalResources();
|
bootstrap.releaseExternalResources();
|
||||||
@ -311,7 +316,7 @@ public class HttpUploadClient {
|
|||||||
*/
|
*/
|
||||||
private static void formpostmultipart(ClientBootstrap bootstrap, String host, int port,
|
private static void formpostmultipart(ClientBootstrap bootstrap, String host, int port,
|
||||||
URI uriFile, HttpDataFactory factory,
|
URI uriFile, HttpDataFactory factory,
|
||||||
List<Entry<String, String>> headers, List<InterfaceHttpData> bodylist) {
|
List<Entry<String, String>> headers, List<InterfaceHttpData> bodylist, boolean forceChunk) {
|
||||||
// XXX /formpostmultipart
|
// XXX /formpostmultipart
|
||||||
// Start the connection attempt.
|
// Start the connection attempt.
|
||||||
ChannelFuture future = bootstrap.connect(new InetSocketAddress(host, port));
|
ChannelFuture future = bootstrap.connect(new InetSocketAddress(host, port));
|
||||||
@ -331,7 +336,7 @@ public class HttpUploadClient {
|
|||||||
HttpPostRequestEncoder bodyRequestEncoder = null;
|
HttpPostRequestEncoder bodyRequestEncoder = null;
|
||||||
try {
|
try {
|
||||||
bodyRequestEncoder = new HttpPostRequestEncoder(factory,
|
bodyRequestEncoder = new HttpPostRequestEncoder(factory,
|
||||||
request, true); // true => multipart
|
request, true, forceChunk); // true => multipart
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
// should not be since no null args
|
// should not be since no null args
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -365,6 +370,7 @@ public class HttpUploadClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// send request
|
// send request
|
||||||
|
System.err.println("Request is chunked? " + request.isChunked() + ":" + bodyRequestEncoder.isChunked());
|
||||||
channel.write(request);
|
channel.write(request);
|
||||||
|
|
||||||
// test if request was chunked and if so, finish the write
|
// test if request was chunked and if so, finish the write
|
||||||
@ -394,7 +400,8 @@ public class HttpUploadClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// use to simulate a big TEXTAREA field in a form
|
// use to simulate a big TEXTAREA field in a form
|
||||||
private static final String textArea =
|
private static final String textArea = "short text";
|
||||||
|
private static final String textAreaLong =
|
||||||
"lkjlkjlKJLKJLKJLKJLJlkj lklkj\r\n\r\nLKJJJJJJJJKKKKKKKKKKKKKKK <20><><EFBFBD><EFBFBD>&\r\n\r\n" +
|
"lkjlkjlKJLKJLKJLKJLJlkj lklkj\r\n\r\nLKJJJJJJJJKKKKKKKKKKKKKKK <20><><EFBFBD><EFBFBD>&\r\n\r\n" +
|
||||||
"MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM\r\n" +
|
"MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM\r\n" +
|
||||||
"MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM\r\n" +
|
"MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM\r\n" +
|
||||||
|
Loading…
x
Reference in New Issue
Block a user