简体   繁体   English

如果标题中的Content-Type是text / html,则重新加载图像

[英]Reload image if Content-Type in header is text/html

I have image generator that sometimes fails and sends a error in text/html while the Status is still 200. 我的图像生成器有时会失败,并且在状态仍为200时以text / html发送错误。

What is the best way to reload the image from the same url if the content-type is not image/jpeg. 如果内容类型不是image / jpeg,从相同的URL重新加载图像的最佳方法是什么。 Should I approach this in a separate php file with curl headers and reload if it's not image/jpeg or is it possible to do on client side in javascript/jquery? 我应该在带有curl标头的单独php文件中处理此问题,如果不是image / jpeg,则重新加载,还是可以在javascript / jquery的客户端执行此操作?

You should fix the image generator script to capture exception and try again. 您应该修复图像生成器脚本以捕获异常,然后重试。 At least return status 500 instead. 至少返回状态500。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM