Search code examples
httpwebserverfavicon

what's the smallest proper answer to http requests for favicon.ico


I am working on a very simple web server.

Till now I haven't found how to disable the annoying requests for favicon.ico from chrome.

So I was thinking what's the shortest/fastest answer to such a request. Is it ok just to disconnect after the request for favicon.ico is identified. Or is that considered impolite behaviour and should be avoided?

Alternativly I would send a 404 message. Do I need to send a text as well or do I have to send at least the information "content-length: 0" or can I even leave this?

Thank you!


Solution

  • According to RFC 2616, the shortest valid response would be

    HTTP/1.0 404 <CRLF>
    <CRLF>
    

    There should be a space between 404 and the line terminator, actually separating the status code from the status reason message (which is an empty string in this case). This might not be strictly required, but I doubt saving a single byte is worth the minor deviation from the RFC.