-
HTTP Messages & MIME types개발/Web 2022. 6. 12. 21:57
*복습 자료라서 뻔한 내용은 생략
Summary.
1. HTTP Message는 Request / Response 2종류이며, multiple ASCII Text Lines
2. The start-line and HTTP headers of the HTTP message are collectively known as the head of the requests, whereas its payload is known as the body
3. Response Body 타입 3가지
- Single-resource bodies, consisting of a single file of known length, defined by the two headers: Content-Type and Content-Length.
- Single-resource bodies, consisting of a single file of unknown length, encoded by chunks with Transfer-Encoding set to chunked.
- Multiple-resource bodies, consisting of a multipart body, each containing a different section of information. These are relatively rare.
4. A media type (also known as a Multipurpose Internet Mail Extensions or MIME type) indicates the nature and format of a document, file, or assortment of bytes. MIME types are defined and standardized in IETF's RFC 6838
+ Browsers use the MIME type, not the file extension, to determine how to process a URL, so it's important that web servers send the correct MIME type in the response's Content-Type header. If this is not correctly configured, browsers are likely to misinterpret the contents of files, sites will not work correctly, and downloaded files may be mishandled.
+ MIME types are case-insensitive but are traditionally written in lowercase. The parameter values can be case-sensitive
+ There are two classes of type: discrete and multipart. Discrete types are types which represent a single file or medium, such as a single text or music file, or a single video. A multipart type is one which represents a document that's comprised of multiple component parts, each of which may have its own individual MIME type; or, a multipart type may encapsulate multiple files being sent together in one transaction. For example, multipart MIME types are used when attaching multiple files to an email
+ Except for multipart/form-data, used in the POST method of HTML Forms, and multipart/byteranges, used with 206 Partial Content to send part of a document, HTTP doesn't handle multipart documents in a special way: the message is transmitted to the browser (which will likely show a "Save As" window if it doesn't know how to display the document) -> message, multipart 2개 타입이 있음
type/subtype;parameter=value
5. 주요 MIME Type 예시
+ application/octet-stream: This is the default for binary files. As it means unknown binary file, browsers usually don't execute it, or even ask if it should be executed. They treat it as if the Content-Disposition header was set to attachment, and propose a "Save As" dialog
+ text/plain: 말 그대로 그냥 text
+ text/css: CSS files used to style a Web page must be sent with text/css
+ text/html: All HTML content should be served with this type. Alternative MIME types for XHTML (like application/xhtml+xml) are mostly useless nowadays
+ text/javascript: Per the current relevant standards, JavaScript content should always be served using the MIME type text/javascript. No other MIME types are considered valid for JavaScript, and using any MIME type other thantext/javascript may result in scripts that do not load or run
6. multipart/form-data, byteranges 예시
+ https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types#multipartform-data
+ https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types#multipartbyteranges
Additional.
1. The Referer HTTP request header contains an absolute or partial address of the page that makes the request. The Referer header allows a server to identify a page where people are visiting it from. This data can be used for analytics, logging, optimized caching, and more
2. The Via general header is added by proxies, both forward and reverse, and can appear in the request or response headers. It is used for tracking message forwards, avoiding request loops, and identifying the protocol capabilities of senders along the request/response chain
3. The Accept-Ranges HTTP response header is a marker used by the server to advertise its support for partial requests from the client for file downloads. The value of this field indicates the unit that can be used to define a range
4. (다음에) img, video, audio MIME 봐보기
5. (다음에) MIME type 설정 관련 트러블 슈팅
Reference.
'개발 > Web' 카테고리의 다른 글
HTTP Authentication (0) 2022.06.12 Web Security (0) 2022.06.12 Same Origin Policy & Cross Origin Resource Sharing (0) 2022.06.11 Content Security Policy (0) 2022.06.11 HTTPS (0) 2022.06.11