HTTP Header
บรรทัด Content-type:text/html\r\n\r\n เป็นส่วนของ HTTP Header ที่ส่งให้ Browser เพื่อเข้าใจ Content HTTP Header ทั้งหมดจะอยู่ในรูปแบบ -
HTTP Field Name - Field Content
ตัวอย่าง
Content-type - text/html\r\n\r\n
มี HTTP Headers สำคัญอื่นๆ ที่ใช้บ่อยใน CGI Programming
| ลำดับ | Header | คำอธิบาย |
|---|---|---|
| 1 | Content-type: | MIME String กำหนด Format ของไฟล์ที่คืนค่า ตัวอย่าง Content-type:text/html |
| 2 | Expires: Date | วันที่ข้อมูลหมดอายุ ใช้โดย Browser ตัดสินใจว่าเมื่อไหร่ควร Refresh Page รูปแบบวันที่ที่ถูกต้อง: 01 Jan 1998 12:00:00 GMT |
| 3 | Location: URL | URL ที่คืนแทน URL ที่ Request ใช้ Redirect Request ไปยังไฟล์อื่นได้ |
| 4 | Last-modified: Date | วันที่แก้ไข Resource ล่าสุด |
| 5 | Content-length: N | ความยาวใน Bytes ของ Data ที่คืนค่า Browser ใช้คำนวณ Estimated Download Time |
| 6 | Set-Cookie: String | ตั้งค่า Cookie ผ่าน String |