我的物聯網設備上有一個網路服務器設定。該設備不是很強大,也沒有用于存盤影像的檔案系統。
盡管如此,我仍然希望為請求它的瀏覽器提供一個圖示。由于我沒有檔案系統,我計劃將影像直接保存到設備的源代碼中。我在這個執行緒中讀到,您可以將影像轉換為編碼字串,然后我可以將編碼字串保存到變數中,例如
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?
uj5u.com熱心網友回復:
您可以生成網站圖示的 base64 字串,然后將其插入到 html 檔案的頭部,如下所示:
<link href="data:image/x-icon;base64,<your_base64_here>" rel="icon" type="image/x-icon" />
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/379882.html
上一篇:C++設計模式:抽象工廠模式
下一篇:如果單元格為空則隱藏行
