My biggest recommendation would be not to use lazy I/O. But excluding that...
You just need to make sure that as much of the input is actually received before sending a response. You do that by forcing evaluation of the thunk. With lazy I/O, forcing evaluation ends up causing I/O to be performed, which is what you want in this case. As an example, to make sure that at least one character is received before continuing, you could use this function:
getSomeContents = do
x <- getContents
case x of
[] -> return x
_:_ -> return x
Another possibility is to use *some* strict I/O. For example, you can get the first character strictly and the rest lazily:
getSomeContents = do
c <- getChar
x <- getContents
return $ c : x
Something else you should think about is what data representation you want to use. Everything we've done here using String, which is (1) inefficient, since it's an unpacked representation, and (2) incorrect, since HTTP data is really a series of bytes, not a series of unicode code points. But I'm going on the assumption that this exercise is more to understand I/O evaluation.