8
8
9
9
package org .smartboot .http ;
10
10
11
- import org .smartboot .http .common .HttpEntityV2 ;
12
- import org .smartboot .http .common .HttpRequestProtocol ;
13
- import org .smartboot .http .common .utils .HttpHeaderConstant ;
14
11
import org .smartboot .http .server .handle .HttpHandle ;
15
- import org .smartboot .http .server .http11 .HttpResponse ;
12
+ import org .smartboot .http .server .v1 .HttpMessageProcessor ;
13
+ import org .smartboot .http .server .v1 .decode .HttpEntity ;
14
+ import org .smartboot .http .server .v1 .decode .HttpRequestProtocol ;
15
+ import org .smartboot .http .utils .HttpHeaderConstant ;
16
16
import org .smartboot .socket .MessageProcessor ;
17
17
import org .smartboot .socket .transport .AioQuickServer ;
18
18
19
19
import java .io .IOException ;
20
20
21
- public class HttpBootstrap {
21
+ public class Bootstrap {
22
22
static byte [] body = "Hello, World!" .getBytes ();
23
23
24
24
public static void main (String [] args ) {
25
- org . smartboot . http . server . HttpV2MessageProcessor processor = new org . smartboot . http . server . HttpV2MessageProcessor (System .getProperty ("webapps.dir" , "./" ));
25
+ HttpMessageProcessor processor = new HttpMessageProcessor (System .getProperty ("webapps.dir" , "./" ));
26
26
processor .route ("/plaintext" , new HttpHandle () {
27
27
28
28
29
29
@ Override
30
- public void doHandle (HttpEntityV2 request , HttpResponse response ) throws IOException {
30
+ public void doHandle (HttpRequest request , HttpResponse response ) throws IOException {
31
31
32
32
response .setHeader (HttpHeaderConstant .Names .CONTENT_LENGTH , body .length + "" );
33
33
response .setHeader (HttpHeaderConstant .Names .CONTENT_TYPE , "text/plain; charset=UTF-8" );
@@ -36,7 +36,7 @@ public void doHandle(HttpEntityV2 request, HttpResponse response) throws IOExcep
36
36
});
37
37
processor .route ("/json" , new HttpHandle () {
38
38
@ Override
39
- public void doHandle (HttpEntityV2 request , HttpResponse response ) throws IOException {
39
+ public void doHandle (HttpRequest request , HttpResponse response ) throws IOException {
40
40
byte [] b = JSON .toJson (new Message ("Hello, World!" ));
41
41
response .setHeader (HttpHeaderConstant .Names .CONTENT_LENGTH , b .length + "" );
42
42
response .setHeader (HttpHeaderConstant .Names .CONTENT_TYPE , "application/json" );
@@ -47,12 +47,11 @@ public void doHandle(HttpEntityV2 request, HttpResponse response) throws IOExcep
47
47
// https(processor);
48
48
}
49
49
50
- public static void http (MessageProcessor <org . smartboot . http . common . HttpEntityV2 > processor ) {
50
+ public static void http (MessageProcessor <HttpEntity > processor ) {
51
51
// 定义服务器接受的消息类型以及各类消息对应的处理器
52
- AioQuickServer <org . smartboot . http . common . HttpEntityV2 > server = new AioQuickServer <org . smartboot . http . common . HttpEntityV2 >(8080 , new HttpRequestProtocol (), processor );
52
+ AioQuickServer <HttpEntity > server = new AioQuickServer <>(8080 , new HttpRequestProtocol (), processor );
53
53
server .setWriteQueueSize (4 );
54
54
server .setReadBufferSize (1024 );
55
- // server.setThreadNum(8);
56
55
try {
57
56
server .start ();
58
57
} catch (IOException e ) {
0 commit comments