Enum should not have a non-final value
This commit is contained in:
parent
e21dc5925d
commit
3d364c7f75
@ -15,11 +15,11 @@
|
|||||||
*/
|
*/
|
||||||
package io.netty.handler.codec.http.multipart;
|
package io.netty.handler.codec.http.multipart;
|
||||||
|
|
||||||
import java.nio.charset.Charset;
|
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.util.CharsetUtil;
|
import io.netty.util.CharsetUtil;
|
||||||
|
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shared Static object between HttpMessageDecoder, HttpPostRequestDecoder and HttpPostRequestEncoder
|
* Shared Static object between HttpMessageDecoder, HttpPostRequestDecoder and HttpPostRequestEncoder
|
||||||
*/
|
*/
|
||||||
@ -97,7 +97,7 @@ final class HttpPostBodyUtil {
|
|||||||
*/
|
*/
|
||||||
BINARY("binary");
|
BINARY("binary");
|
||||||
|
|
||||||
public String value;
|
private final String value;
|
||||||
|
|
||||||
TransferEncodingMechanism(String value) {
|
TransferEncodingMechanism(String value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
@ -107,6 +107,10 @@ final class HttpPostBodyUtil {
|
|||||||
value = name();
|
value = name();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String value() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return value;
|
return value;
|
||||||
|
@ -1084,12 +1084,12 @@ public class HttpPostRequestDecoder {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new ErrorDataDecoderException(e);
|
throw new ErrorDataDecoderException(e);
|
||||||
}
|
}
|
||||||
if (code.equals(HttpPostBodyUtil.TransferEncodingMechanism.BIT7.value)) {
|
if (code.equals(HttpPostBodyUtil.TransferEncodingMechanism.BIT7.value())) {
|
||||||
localCharset = HttpPostBodyUtil.US_ASCII;
|
localCharset = HttpPostBodyUtil.US_ASCII;
|
||||||
} else if (code.equals(HttpPostBodyUtil.TransferEncodingMechanism.BIT8.value)) {
|
} else if (code.equals(HttpPostBodyUtil.TransferEncodingMechanism.BIT8.value())) {
|
||||||
localCharset = HttpPostBodyUtil.ISO_8859_1;
|
localCharset = HttpPostBodyUtil.ISO_8859_1;
|
||||||
mechanism = TransferEncodingMechanism.BIT8;
|
mechanism = TransferEncodingMechanism.BIT8;
|
||||||
} else if (code.equals(HttpPostBodyUtil.TransferEncodingMechanism.BINARY.value)) {
|
} else if (code.equals(HttpPostBodyUtil.TransferEncodingMechanism.BINARY.value())) {
|
||||||
// no real charset, so let the default
|
// no real charset, so let the default
|
||||||
mechanism = TransferEncodingMechanism.BINARY;
|
mechanism = TransferEncodingMechanism.BINARY;
|
||||||
} else {
|
} else {
|
||||||
@ -1122,7 +1122,7 @@ public class HttpPostRequestDecoder {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
currentFileUpload = factory.createFileUpload(request, nameAttribute.getValue(),
|
currentFileUpload = factory.createFileUpload(request, nameAttribute.getValue(),
|
||||||
filenameAttribute.getValue(), contentTypeAttribute.getValue(), mechanism.value, localCharset,
|
filenameAttribute.getValue(), contentTypeAttribute.getValue(), mechanism.value(), localCharset,
|
||||||
size);
|
size);
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
throw new ErrorDataDecoderException(e);
|
throw new ErrorDataDecoderException(e);
|
||||||
|
@ -320,7 +320,7 @@ public class HttpPostRequestEncoder implements ChunkedMessageInput<HttpChunk> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!isText) {
|
if (!isText) {
|
||||||
contentTransferEncoding = HttpPostBodyUtil.TransferEncodingMechanism.BINARY.value;
|
contentTransferEncoding = HttpPostBodyUtil.TransferEncodingMechanism.BINARY.value();
|
||||||
}
|
}
|
||||||
FileUpload fileUpload = factory.createFileUpload(request, name, file.getName(), scontentType,
|
FileUpload fileUpload = factory.createFileUpload(request, name, file.getName(), scontentType,
|
||||||
contentTransferEncoding, null, file.length());
|
contentTransferEncoding, null, file.length());
|
||||||
@ -573,9 +573,9 @@ public class HttpPostRequestEncoder implements ChunkedMessageInput<HttpChunk> {
|
|||||||
internal.addValue(HttpHeaders.Names.CONTENT_TYPE + ": " + fileUpload.getContentType());
|
internal.addValue(HttpHeaders.Names.CONTENT_TYPE + ": " + fileUpload.getContentType());
|
||||||
String contentTransferEncoding = fileUpload.getContentTransferEncoding();
|
String contentTransferEncoding = fileUpload.getContentTransferEncoding();
|
||||||
if (contentTransferEncoding != null
|
if (contentTransferEncoding != null
|
||||||
&& contentTransferEncoding.equals(HttpPostBodyUtil.TransferEncodingMechanism.BINARY.value)) {
|
&& contentTransferEncoding.equals(HttpPostBodyUtil.TransferEncodingMechanism.BINARY.value())) {
|
||||||
internal.addValue("\r\n" + HttpHeaders.Names.CONTENT_TRANSFER_ENCODING + ": "
|
internal.addValue("\r\n" + HttpHeaders.Names.CONTENT_TRANSFER_ENCODING + ": "
|
||||||
+ HttpPostBodyUtil.TransferEncodingMechanism.BINARY.value + "\r\n\r\n");
|
+ HttpPostBodyUtil.TransferEncodingMechanism.BINARY.value() + "\r\n\r\n");
|
||||||
} else if (fileUpload.getCharset() != null) {
|
} else if (fileUpload.getCharset() != null) {
|
||||||
internal.addValue("; " + HttpHeaders.Values.CHARSET + "=" + fileUpload.getCharset() + "\r\n\r\n");
|
internal.addValue("; " + HttpHeaders.Values.CHARSET + "=" + fileUpload.getCharset() + "\r\n\r\n");
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user