package org.yukung.sandbox.http;

import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @author yukung
 */
public class Main {
    public static void main(String[] args) throws IOException {
        System.out.println("start >>>");

        try (
                ServerSocket ss = new ServerSocket(8080);
                Socket socket = ss.accept();
                InputStream in = socket.getInputStream()
        ) {
            HttpRequest request = new HttpRequest(in);

            System.out.println(request.getHeaderText());
            System.out.println(request.getBodyText());
        }

        System.out.println("<<< end");
    }
}

@@ -27,16 +27,104 @@
 .http;%0A%0A
+import static org.yukung.sandbox.http.HttpRequest.CRLF;%0A%0Aimport java.io.BufferedWriter;%0A
 import j
@@ -171,16 +171,51 @@
 Stream;%0A
+import java.io.OutputStreamWriter;%0A
 import j
@@ -439,20 +439,16 @@
         
-    
 ServerSo
@@ -481,20 +481,16 @@
 (8080);%0A
-    
         
@@ -534,20 +534,16 @@
         
-    
 InputStr
@@ -574,16 +574,118 @@
 Stream()
+;%0A            BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()))
 %0A       
@@ -848,32 +848,81 @@
 .getBodyText());
+%0A%0A            bw.write(%22HTTP/1.1 200 OK%22 + CRLF);
 %0A        %7D%0A%0A    

Return the status line of response header.