I\'m writing an HTTP server, and am having trouble sending larger files. If I grab them with netcat, the output seems perfect. If I use a browser or wget, I only get the complet
My guess is that the error is related to code you have not shown here.
It is a common mistake in simple implementation to not fully read the request but instead only read the first line or some bytes to determine the requested page, then send the response and finally close.
Since at the time of the close there are still unread data from the client, this will result in Connection reset by peer. You don't see this effect with nc because the request you send with nc is probably shorter than the request from the browser and thus all data from the request are read in case of nc, but not in case of browser.
Apart from that your response is invalid even if browsers accept it. Your status line (the first line) stops after the status code instead of adding the reason phrase, see http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html#sec6.1. Also, you use \n
instead of \r\n
as line delimiter.