Browse Source

update to 1.0.10-beta (#4197)

* update dockerfile

* update to 1.0.10-SNAPSHOT

* update to 1.0.10-beta

* fix bug
三刀 6 years ago
parent
commit
d229753616

+ 1 - 1
frameworks/Java/smart-socket/pom.xml

@@ -9,7 +9,7 @@
     <parent>
         <groupId>org.smartboot.http</groupId>
         <artifactId>smart-http-parent</artifactId>
-        <version>1.0.9</version>
+        <version>1.0.10-beta</version>
     </parent>
     <properties>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

+ 6 - 9
frameworks/Java/smart-socket/src/main/java/org/smartboot/http/Bootstrap.java

@@ -12,7 +12,6 @@ import org.smartboot.http.server.HttpMessageProcessor;
 import org.smartboot.http.server.decode.Http11Request;
 import org.smartboot.http.server.decode.HttpRequestProtocol;
 import org.smartboot.http.server.handle.HttpHandle;
-import org.smartboot.http.utils.HttpHeaderConstant;
 import org.smartboot.socket.MessageProcessor;
 import org.smartboot.socket.transport.AioQuickServer;
 
@@ -22,16 +21,15 @@ public class Bootstrap {
     static byte[] body = "Hello, World!".getBytes();
 
     public static void main(String[] args) {
-        System.setProperty("sun.nio.ch.maxCompletionHandlersOnStack","0");
+        System.setProperty("smart-socket.server.pageSize", (4 * 1024 * 1024) + "");
         HttpMessageProcessor processor = new HttpMessageProcessor(System.getProperty("webapps.dir", "./"));
         processor.route("/plaintext", new HttpHandle() {
 
 
             @Override
             public void doHandle(HttpRequest request, HttpResponse response) throws IOException {
-
-                response.setHeader(HttpHeaderConstant.Names.CONTENT_LENGTH, body.length + "");
-                response.setHeader(HttpHeaderConstant.Names.CONTENT_TYPE, "text/plain; charset=UTF-8");
+                response.setContentLength(body.length);
+                response.setContentType("text/plain; charset=UTF-8");
                 response.getOutputStream().write(body);
             }
         });
@@ -39,8 +37,8 @@ public class Bootstrap {
             @Override
             public void doHandle(HttpRequest request, HttpResponse response) throws IOException {
                 byte[] b = JSON.toJson(new Message("Hello, World!"));
-                response.setHeader(HttpHeaderConstant.Names.CONTENT_LENGTH, b.length + "");
-                response.setHeader(HttpHeaderConstant.Names.CONTENT_TYPE, "application/json");
+                response.setContentLength(b.length);
+                response.setContentType("application/json");
                 response.getOutputStream().write(b);
             }
         });
@@ -51,8 +49,7 @@ public class Bootstrap {
     public static void http(MessageProcessor<Http11Request> processor) {
         // 定义服务器接受的消息类型以及各类消息对应的处理器
         AioQuickServer<Http11Request> server = new AioQuickServer<>(8080, new HttpRequestProtocol(), processor);
-        server.setWriteQueueSize(1024);
-        server.setReadBufferSize(1024*4);
+        server.setReadBufferSize(1024);
 //        server.setThreadNum((int) (Runtime.getRuntime().availableProcessors() * 2));
         try {
             server.start();