text/html 與 application/html的區別


簡而言之:

text/html, 表示的是文件編碼方式首先使用響應頭content-type指定的編碼方式來解碼,如果請求頭沒有指定則使用ASCII。文件類型為html。

application/html,表示的是文件編碼方式首先使用文件頭指定的格式,其次使用響應頭指定的方式,如果都沒有則使用ASCII。文件類型為html。

 

詳細解析:

XML has two MIME types,application/xml and text/xml . These are often used interchangeably, but there is a subtle difference which is why application/xml is generally recommended over the latter.

XML有兩種媒體類型(MIME),application/xml 和 text/xml。雖然這兩種類型非常相似經常可以互換使用,但它們之間依然后一個非常明顯的區別。權威人士一般推薦使用 application/xml,以下展開說明以下它們之間的區別。


Let me explain why: according to the standard, text/* -MIME types have a us-ascii character set unless otherwise specified in the HTTP headers. This effectively means that any encoding defined in the XML prolog (e.g. <?xml version=”1.0” encoding=”UTF-8”?>) is ignored. This is of course not the expected and desired behaviour.

在一次響應中,有兩個地方可以指定響應內容的格式,一個是響應頭的content-type字段,另一個是xml的序言部分(prolog,e.g. <?xml version="1.0", encoding="UTF-8"?>)。根據定義,如果是text/* 則在解析響應體內容時,首先會根據響應頭指定的格式,如果響應頭沒有指定,則使用ascii,忽略xml序言中指定的格式。如果是application/* 則首先使用xml序言中指定的格式,而后使用響應頭中指定的格式,如果都沒有指定才使用ascii格式解析。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM