The problem is that you might receive the http request in pieces, that’s normal, so a single socket read does not guarantee you the whole msg, you have to do couple of socket read to get the whole request, then do that m// or whatever you want.
Comment on Re: Reading in Post Variables from a socket