【发布时间】:2022-01-15 18:54:11
【问题描述】:
我在我的 iot 设备上设置了网络服务器。该设备不是很强大,也没有用于存储图像的文件系统。
尽管如此,我仍然希望为请求它的浏览器提供一个网站图标。由于我没有文件系统,我计划将图像直接保存到设备的源代码中。我在this thread 中读到,您可以将图像转换为编码字符串,然后我可以将编码字符串保存到变量中,例如
String imageString = "Encoded String Here";
所以这是 google chrome favicon http 请求的样子
20:46:21.767 -> GET /favicon.ico HTTP/1.1
20:46:21.767 -> Host: 192.168.1.8
20:46:21.767 -> Connection: keep-alive
20:46:21.767 -> User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36
20:46:21.814 -> Accept: image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8
20:46:21.814 -> Referer: http://192.168.1.8/
20:46:21.814 -> Accept-Encoding: gzip, deflate
20:46:21.814 -> Accept-Language: en-US,en;q=0.9,fil;q=0.8
我的网络服务器只能以纯文本响应请求。那么我的响应看起来如何,图像现在是文本格式??
HTTP/1.1 200 OK
Connection: close
Content-Type: text/html
//Do i place the encoded string here?? will the browser understand that?
【问题讨论】: