Fix overly-strong type casts
This commit is contained in:
parent
90c0481ecf
commit
994a8db8fc
@ -15,6 +15,17 @@
|
||||
*/
|
||||
package io.netty.handler.codec.http.multipart;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.MessageBuf;
|
||||
import io.netty.handler.codec.http.DefaultHttpChunk;
|
||||
import io.netty.handler.codec.http.HttpChunk;
|
||||
import io.netty.handler.codec.http.HttpConstants;
|
||||
import io.netty.handler.codec.http.HttpHeaders;
|
||||
import io.netty.handler.codec.http.HttpMethod;
|
||||
import io.netty.handler.codec.http.HttpRequest;
|
||||
import io.netty.handler.codec.http.HttpTransferEncoding;
|
||||
import io.netty.handler.stream.ChunkedMessageInput;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
@ -26,16 +37,6 @@ import java.util.ListIterator;
|
||||
import java.util.Random;
|
||||
|
||||
import static io.netty.buffer.Unpooled.*;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.MessageBuf;
|
||||
import io.netty.handler.codec.http.DefaultHttpChunk;
|
||||
import io.netty.handler.codec.http.HttpChunk;
|
||||
import io.netty.handler.codec.http.HttpConstants;
|
||||
import io.netty.handler.codec.http.HttpHeaders;
|
||||
import io.netty.handler.codec.http.HttpMethod;
|
||||
import io.netty.handler.codec.http.HttpRequest;
|
||||
import io.netty.handler.codec.http.HttpTransferEncoding;
|
||||
import io.netty.handler.stream.ChunkedMessageInput;
|
||||
|
||||
/**
|
||||
* This encoder will help to encode Request for a FORM as POST.
|
||||
@ -766,7 +767,7 @@ public class HttpPostRequestEncoder implements ChunkedMessageInput<HttpChunk> {
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
buffer = ((FileUpload) currentData).getChunk(sizeleft);
|
||||
buffer = ((HttpData) currentData).getChunk(sizeleft);
|
||||
} catch (IOException e) {
|
||||
throw new ErrorDataEncoderException(e);
|
||||
}
|
||||
@ -829,7 +830,7 @@ public class HttpPostRequestEncoder implements ChunkedMessageInput<HttpChunk> {
|
||||
|
||||
// Put value into buffer
|
||||
try {
|
||||
buffer = ((Attribute) currentData).getChunk(size);
|
||||
buffer = ((HttpData) currentData).getChunk(size);
|
||||
} catch (IOException e) {
|
||||
throw new ErrorDataEncoderException(e);
|
||||
}
|
||||
|
@ -15,8 +15,6 @@
|
||||
*/
|
||||
package io.netty.example.http.upload;
|
||||
|
||||
import static io.netty.buffer.Unpooled.copiedBuffer;
|
||||
import static io.netty.handler.codec.http.HttpHeaders.Names.SET_COOKIE;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
@ -59,6 +57,9 @@ import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import static io.netty.buffer.Unpooled.*;
|
||||
import static io.netty.handler.codec.http.HttpHeaders.Names.*;
|
||||
|
||||
public class HttpUploadServerHandler extends ChannelInboundMessageHandlerAdapter<Object> {
|
||||
|
||||
private static final InternalLogger logger = InternalLoggerFactory.getInstance(HttpUploadServerHandler.class);
|
||||
@ -273,7 +274,7 @@ public class HttpUploadServerHandler extends ChannelInboundMessageHandlerAdapter
|
||||
if (fileUpload.length() < 10000) {
|
||||
responseContent.append("\tContent of file\r\n");
|
||||
try {
|
||||
responseContent.append(((FileUpload) data).getString(((FileUpload) data).getCharset()));
|
||||
responseContent.append(fileUpload.getString(fileUpload.getCharset()));
|
||||
} catch (IOException e1) {
|
||||
// do nothing for the example
|
||||
e1.printStackTrace();
|
||||
|
Loading…
Reference in New Issue
Block a user