I am learning erlang, and am trying to build an Http Server to better learn about how erlang works, I am able to get the request:
<<"GET / HTTP/1.1\r\nHost: 127.0.0.1:8000\r\nConnection: keep-alive\r\nCache-Control: max-age=0\r\nAccept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,/;q=0.5\r\nUser-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.3 (KHTML, like Gecko) Chrome/6.0.472.51 Safari/534.3\r\nAccept-Encoding: gzip,deflate,sdch\r\nAccept-Language: en-US,en;q=0.8\r\nAccept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3\r\n\r\n">>
but I'm not exactly sure how to begin pattern matching, or am wondering if I'm going to have to build a FSM or something to keep track of the current parses and the state. Is there a simple method to extract headers and body using pattern matching, maybe splitting on \r\n? I'd prefer not to use something like mochiweb, since I am trying to learn fundamentals.