This commit is contained in:
@@ -22,8 +22,6 @@ import org.redkale.util.*;
|
|||||||
*/
|
*/
|
||||||
public class JsonByteBufferWriter extends JsonWriter {
|
public class JsonByteBufferWriter extends JsonWriter {
|
||||||
|
|
||||||
protected static final Charset UTF8 = Charset.forName("UTF-8");
|
|
||||||
|
|
||||||
protected Charset charset;
|
protected Charset charset;
|
||||||
|
|
||||||
private final Supplier<ByteBuffer> supplier;
|
private final Supplier<ByteBuffer> supplier;
|
||||||
@@ -38,7 +36,7 @@ public class JsonByteBufferWriter extends JsonWriter {
|
|||||||
|
|
||||||
protected JsonByteBufferWriter(boolean tiny, Charset charset, Supplier<ByteBuffer> supplier) {
|
protected JsonByteBufferWriter(boolean tiny, Charset charset, Supplier<ByteBuffer> supplier) {
|
||||||
this.tiny = tiny;
|
this.tiny = tiny;
|
||||||
this.charset = UTF8.equals(charset) ? null : charset;
|
this.charset = StandardCharsets.UTF_8.equals(charset) ? null : charset;
|
||||||
this.supplier = supplier;
|
this.supplier = supplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,8 +28,6 @@ import org.redkale.util.*;
|
|||||||
*/
|
*/
|
||||||
public class Context {
|
public class Context {
|
||||||
|
|
||||||
private static final Charset UTF8 = Charset.forName("UTF-8");
|
|
||||||
|
|
||||||
//服务启动时间
|
//服务启动时间
|
||||||
protected final long serverStartTime;
|
protected final long serverStartTime;
|
||||||
|
|
||||||
@@ -90,7 +88,7 @@ public class Context {
|
|||||||
this.bufferPool = bufferPool;
|
this.bufferPool = bufferPool;
|
||||||
this.responsePool = responsePool;
|
this.responsePool = responsePool;
|
||||||
this.maxbody = maxbody;
|
this.maxbody = maxbody;
|
||||||
this.charset = UTF8.equals(charset) ? null : charset;
|
this.charset = StandardCharsets.UTF_8.equals(charset) ? null : charset;
|
||||||
this.address = address;
|
this.address = address;
|
||||||
this.prepare = prepare;
|
this.prepare = prepare;
|
||||||
this.resourceFactory = resourceFactory;
|
this.resourceFactory = resourceFactory;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import java.io.*;
|
|||||||
import java.net.*;
|
import java.net.*;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.channels.Channels;
|
import java.nio.channels.Channels;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import org.redkale.convert.json.JsonConvert;
|
import org.redkale.convert.json.JsonConvert;
|
||||||
import org.redkale.net.*;
|
import org.redkale.net.*;
|
||||||
@@ -31,8 +31,6 @@ import org.redkale.util.AnyValue.DefaultAnyValue;
|
|||||||
*/
|
*/
|
||||||
public class HttpRequest extends Request<HttpContext> {
|
public class HttpRequest extends Request<HttpContext> {
|
||||||
|
|
||||||
protected static final Charset UTF8 = Charset.forName("UTF-8");
|
|
||||||
|
|
||||||
public static final String SESSIONID_NAME = "JSESSIONID";
|
public static final String SESSIONID_NAME = "JSESSIONID";
|
||||||
|
|
||||||
@Comment("Method GET/POST/...")
|
@Comment("Method GET/POST/...")
|
||||||
@@ -340,7 +338,7 @@ public class HttpRequest extends Request<HttpContext> {
|
|||||||
* @return 内容
|
* @return 内容
|
||||||
*/
|
*/
|
||||||
public String getBodyUTF8() {
|
public String getBodyUTF8() {
|
||||||
return array.toString(UTF8);
|
return array.toString(StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -352,7 +350,7 @@ public class HttpRequest extends Request<HttpContext> {
|
|||||||
* @return 内容
|
* @return 内容
|
||||||
*/
|
*/
|
||||||
public <T> T getBodyJson(java.lang.reflect.Type type) {
|
public <T> T getBodyJson(java.lang.reflect.Type type) {
|
||||||
String str = array.toString(UTF8);
|
String str = array.toString(StandardCharsets.UTF_8);
|
||||||
if (str == null || str.isEmpty()) return null;
|
if (str == null || str.isEmpty()) return null;
|
||||||
return context.getJsonConvert().convertFrom(type, str);
|
return context.getJsonConvert().convertFrom(type, str);
|
||||||
}
|
}
|
||||||
@@ -367,7 +365,7 @@ public class HttpRequest extends Request<HttpContext> {
|
|||||||
* @return 内容
|
* @return 内容
|
||||||
*/
|
*/
|
||||||
public <T> T getBodyJson(JsonConvert convert, java.lang.reflect.Type type) {
|
public <T> T getBodyJson(JsonConvert convert, java.lang.reflect.Type type) {
|
||||||
String str = array.toString(UTF8);
|
String str = array.toString(StandardCharsets.UTF_8);
|
||||||
if (str == null || str.isEmpty()) return null;
|
if (str == null || str.isEmpty()) return null;
|
||||||
return convert.convertFrom(type, str);
|
return convert.convertFrom(type, str);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,8 +26,6 @@ public final class MultiContext {
|
|||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(MultiContext.class.getSimpleName());
|
private static final Logger logger = Logger.getLogger(MultiContext.class.getSimpleName());
|
||||||
|
|
||||||
private static final Charset UTF8 = Charset.forName("UTF-8");
|
|
||||||
|
|
||||||
private final String contentType;
|
private final String contentType;
|
||||||
|
|
||||||
private final InputStream in;
|
private final InputStream in;
|
||||||
@@ -58,7 +56,7 @@ public final class MultiContext {
|
|||||||
};
|
};
|
||||||
|
|
||||||
public MultiContext(final Charset charsetName, final String contentType, final DefaultAnyValue params, final InputStream in, String fielnameRegex) {
|
public MultiContext(final Charset charsetName, final String contentType, final DefaultAnyValue params, final InputStream in, String fielnameRegex) {
|
||||||
this.charset = charsetName == null ? UTF8 : charsetName;
|
this.charset = charsetName == null ? StandardCharsets.UTF_8 : charsetName;
|
||||||
this.contentType = contentType == null ? "" : contentType.trim();
|
this.contentType = contentType == null ? "" : contentType.trim();
|
||||||
this.parameters = params;
|
this.parameters = params;
|
||||||
this.boundary = parseBoundary(this.contentType);
|
this.boundary = parseBoundary(this.contentType);
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ package org.redkale.net.http;
|
|||||||
import org.redkale.util.Utility;
|
import org.redkale.util.Utility;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.AbstractMap;
|
import java.util.AbstractMap;
|
||||||
import java.util.function.*;
|
import java.util.function.*;
|
||||||
import java.util.logging.*;
|
import java.util.logging.*;
|
||||||
@@ -24,8 +24,6 @@ import org.redkale.net.Cryptor;
|
|||||||
*/
|
*/
|
||||||
public final class WebSocketPacket {
|
public final class WebSocketPacket {
|
||||||
|
|
||||||
private static final Charset UTF_8 = Charset.forName("UTF-8");
|
|
||||||
|
|
||||||
static final WebSocketPacket NONE = new WebSocketPacket();
|
static final WebSocketPacket NONE = new WebSocketPacket();
|
||||||
|
|
||||||
public static final WebSocketPacket DEFAULT_PING_PACKET = new WebSocketPacket(FrameType.PING, new byte[0]);
|
public static final WebSocketPacket DEFAULT_PING_PACKET = new WebSocketPacket(FrameType.PING, new byte[0]);
|
||||||
@@ -480,7 +478,7 @@ public final class WebSocketPacket {
|
|||||||
if (this.type == FrameType.TEXT) {
|
if (this.type == FrameType.TEXT) {
|
||||||
Convert textConvert = webSocket.getTextConvert();
|
Convert textConvert = webSocket.getTextConvert();
|
||||||
if (textConvert == null) {
|
if (textConvert == null) {
|
||||||
this.receiveMessage = new String(this.getReceiveBytes(buffers), UTF_8);
|
this.receiveMessage = new String(this.getReceiveBytes(buffers), StandardCharsets.UTF_8);
|
||||||
this.receiveType = MessageType.STRING;
|
this.receiveType = MessageType.STRING;
|
||||||
} else {
|
} else {
|
||||||
this.receiveMessage = textConvert.convertFrom(webSocket._messageTextType, this.receiveMasker, buffers);
|
this.receiveMessage = textConvert.convertFrom(webSocket._messageTextType, this.receiveMasker, buffers);
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import java.net.*;
|
|||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.channels.CompletionHandler;
|
import java.nio.channels.CompletionHandler;
|
||||||
import java.nio.charset.*;
|
import java.nio.charset.*;
|
||||||
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
import java.time.*;
|
import java.time.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.*;
|
import java.util.function.*;
|
||||||
@@ -31,8 +32,6 @@ public final class Utility {
|
|||||||
|
|
||||||
private static final String format = "%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS";
|
private static final String format = "%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS";
|
||||||
|
|
||||||
private static final Charset UTF_8 = Charset.forName("UTF-8");
|
|
||||||
|
|
||||||
private static final char hex[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
|
private static final char hex[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user