Correct HTTP Headers for Images?

无人久伴 提交于 2019-12-06 04:40:41

问题


I'm writing a web server in C#, just for the fun of it, and I am able to serve basic text files to my browser. However, when serving up an image (say, image.png), all browsers that I test my server on (IE, Firefox, and Chrome) show some kind of placeholder thumbnail for the image, as if the image is corrupted or invalid.

The response that I am sending to the browser looks like

HTTP/1.0 200 Ok
Content-Type: image/png
Content-Length: 14580053

{image data here}

Am I using the correct HTTP headers? Or, if I am, why else would browsers not accept the image?


回答1:


Ah, figured it out... my code forgot to add an extra \n before the response body. It wasn't a problem with the headers at all, just incorrect response syntax.



来源:https://stackoverflow.com/questions/20247795/correct-http-headers-for-images

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!