|
@@ -1,5 +1,7 @@
|
|
|
package com.litongjava.tio.http.server.handler;
|
|
|
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
+
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
import com.litongjava.tio.boot.http.TioRequestContext;
|
|
|
import com.litongjava.tio.http.common.HttpRequest;
|
|
@@ -8,16 +10,15 @@ import com.litongjava.tio.http.common.utils.MimeTypeUtils;
|
|
|
import com.litongjava.tio.http.server.model.Message;
|
|
|
|
|
|
/**
|
|
|
- * ab -k -n1000000 -c10 http://127.0.0.1:8080/json
|
|
|
- * ab -k -n1000000 -c10 http://127.0.0.1:8080/plaintext
|
|
|
+ * ab -k -n1000000 -c10 http://127.0.0.1:8080/json ab -k -n1000000 -c10
|
|
|
+ * http://127.0.0.1:8080/plaintext
|
|
|
*/
|
|
|
public class IndexHandler {
|
|
|
- private static final String HELLO_WORLD_RN = "Hello, World!\r\n";
|
|
|
-
|
|
|
+
|
|
|
private static final String HELLO_WORLD = "Hello, World!";
|
|
|
|
|
|
- private static final byte[] HELLO_WORLD_BYTES = HELLO_WORLD_RN.getBytes();
|
|
|
- private static byte[] JSON_BYTES = JSON.toJSONBytes(new Message(HELLO_WORLD));
|
|
|
+ private static final byte[] HELLO_WORLD_BYTES = HELLO_WORLD.getBytes(StandardCharsets.UTF_8);
|
|
|
+ private static final byte[] JSON_BYTES = JSON.toJSONBytes(new Message(HELLO_WORLD));
|
|
|
|
|
|
public HttpResponse plaintext(HttpRequest request) {
|
|
|
HttpResponse response = TioRequestContext.getResponse();
|