import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.Socket;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by aditya on 1/9/16.
 */
public class Request {

    private Map<String, String> headerFields = new HashMap<String, String>();
    private String protocol, request, method, content;

    public Request(Socket client) throws IOException{
        BufferedReader in = new BufferedReader(
                new InputStreamReader(client.getInputStream()));

        String statusLine = in.readLine();
        String keywords[] = statusLine.split(" ");
        method = keywords[0];
        request = keywords[1];
        protocol = keywords[2];

        String line = "";
        byte state = 0;
        char alphabet;
        while(true){
            alphabet = (char)in.read();
            if(state == 0){
                if(alphabet == '\r') {
                    state = 1;
                }
                else{
                    line += alphabet;
                }
            }
            else if(state == 1){
                if(alphabet == '\n'){
                    state = 2;
                    String arr[] = line.split(":");
                    headerFields.put(arr[0], arr[1]);
                    line = "";
                }
                else{
                    line += alphabet;
                }
            }
            else if(state == 2){
                if(alphabet == '\r'){
                    in.read();
                    break;
                }
                else{
                    line += alphabet;
                    state = 0;
                }
            }
        }

        if(headerFields.get("Content-Length") != null) {
            int messageLength = Integer.parseInt(headerFields.get("Content-Length").trim());
            content = "";
            for (int i = 0; i < messageLength; i++) {
                content += (char) in.read();
            }
        }
    }

    public Map getHeaderFields(){
        return headerFields;
    }

    public String getRequestURL(){
        return request;
    }

    public String getMethod(){
        return method;
    }

    public String getContent(){
        return content;
    }

    public String getProtocol(){
        return protocol;
    }

}

@@ -1,20 +1,1509 @@
+/*%0ACopyright (c) 2016, Aditya Ambadipudi%0AAll rights reserved.%0A%0ARedistribution and use in source and binary forms, with or without%0Amodification, are permitted provided that the following conditions are met:%0A%0A* Redistributions of source code must retain the above copyright notice, this%0A  list of conditions and the following disclaimer.%0A%0A* Redistributions in binary form must reproduce the above copyright notice,%0A  this list of conditions and the following disclaimer in the documentation%0A  and/or other materials provided with the distribution.%0A%0A* Neither the name of SilkRoad nor the names of its%0A  contributors may be used to endorse or promote products derived from%0A  this software without specific prior written permission.%0A%0ATHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS %22AS IS%22%0AAND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE%0AIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE%0ADISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE%0AFOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL%0ADAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR%0ASERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER%0ACAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,%0AOR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE%0AOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.%0A*/%0A
 import java.io.Buffe

Update Request.java