MIME-typer i HTTP-protokollet

MIME-typer gör det möjligt att specificera typen av mottagen fil så att webbläsaren kan bearbeta den korrekt.

Till exempel ska webbläsaren förstå att den mottagna filen innehåller CSS, eller en bild och tolka dem på lämpligt sätt.

Naturligtvis kan denna information oftast hämtas från filändelsen. Till exempel är det uppenbart att en fil med ändelsen .css innehåller CSS-stilar. Men det blir enklare för webbläsaren om innehållstypen anges explicit.

Angivande av MIME-typ i HTTP-protokollet görs i huvudet Content-Type. Låt oss titta på de mest populära alternativen.

Innehåll - HTML-kod:

httpContent-Type: text/html

Innehåll - CSS-kod:

httpContent-Type: text/css

Innehåll - JavaScript-kod:

httpContent-Type: text/javascript

Innehåll - vanlig text:

httpContent-Type: text/plain

Innehåll - PNG-bild:

httpContent-Type: image/png

Innehåll - JPG-bild:

httpContent-Type: image/jpeg

Innehåll - text i JSON-format:

httpContent-Type: application/json

Innehåll - text i XML-format:

httpContent-Type: text/xml