Tham khảo tài liệu 'web client programming with perl-chapter 3: learning http- p3', công nghệ thông tin, quản trị web phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Chapter 3 Learning HTTP- P3 HTTP Headers Now we re ready for the meat of HTTP the headers that clients and servers can use to exchange information about the data or about the software itself. If the Web were just a matter of retrieving documents blindly then HTTP would have been sufficient for all our needs. But as it turns out there s a whole set of information we d like to exchange in addition to the documents themselves. A client might ask the server What kind of document are you sending Or I already have an older copy of this document--do I need to bother you for a new one A server may want to know Who are you Or Who sent you here Or How am I supposed to know you re allowed to be here All this extra meta- information is passed between the client and server using HTTP headers. The headers are specified immediately after the initial line of the transaction which is used for the client request or server response line . Any number of headers can be specified followed by a blank line and then the entity-body itself if any . HTTP makes a distinction between four different types of headers General headers indicate general information such as the date or whether the connection should be maintained. They are used by both clients and servers. Request headers are used only for client requests. They convey the client s configuration and desired document format to the server. Response headers are used only in server responses. They describe the server s configuration and special information about the requested URL. Entity headers describe the document format of the data being sent between client and server. Although Entity headers are most commonly used by the server when returning a requested document they are also used by clients when using the POST or PUT methods. Headers from all three categories may be specified in any order. Header names are case-insensitive so the Content-Type header is also frequently written as Content-type. In the remainder of this chapter we