280 likes | 450 Views
Hyper Text Transfer Protocol. Seree Chinodom seree@buu.ac.th. Network Protocols. Layered Approach to Networks Transport Layer Protocols Application Layer Protocols. Types of Transport Layer Services. Connectionless User Datagram Protocol (UDP)
E N D
Hyper Text Transfer Protocol Seree Chinodom seree@buu.ac.th
Network Protocols • Layered Approach to Networks • Transport Layer Protocols • Application Layer Protocols
Types of Transport Layer Services • ConnectionlessUser Datagram Protocol (UDP) • Connection OrientedTransmission Contorl Protocol (TCP)
HTTP • HyperText Transfer Protocal • Application Layer Protocol • เป็น Connection Oriented Service • ทำงานโดยใช้ Request-Response Model
HTTP Versions • HTTP/0.9 เมื่อปี 1990 • HTTP/1.0 (RFC 1945) เมื่อปี 1992 • MINE ทำให้ส่งข้อมูลแบบสื่อผสมได้ • ปัจจุบัน : HTTP/1.1 (RFC 2068) • ปี 1997 • อนาคต: HTTP Next Generation
Uniform Resource Identifier : URI • Uniform Resource Locator(URL) • Uniform Resource Name (URN) Protocall://<Host[:Port_Number ]>/<File_Name> Protocall ได้แก่ http, FTP,WAIS,Telnet, Gopher,News Host_Nameใช้ระบุชื่อเครื่องหรือ IP address Port_Numberหมายเลขพอร์ตที่ใช้ติดต่อกับ Web Server File_Nameใช้ระบุชื่อไฟล์หรือเอกสาร HTML โดยต้องระบุ path ของไฟล์ด้วย
Date and Time • HTTP/1.1 กำหนดวัน เวลาได้ 3แบบ • RFC 1123 • Sun, 06Nov199808:59:59GMT • RFC 1036 • Sunday, 06Nov9808:59:59GMT • asctime() ของ ANSI C • SunNov608:59:591998GMT • GMT :Greenwich Mean Time
Basic HTTP • เป็นการทำงานแบบ Request/Response • HTTP Request Header • บรรจุข้อมูลต่างๆที่จะบอกให้ serverทราบ • เงื่อนไขและข้อมูล • HTTP Response Header • เอกสารที่เบราเซอร์ต้องการ
HTTP Messages • Message HeaderMessage Body • Request/Response Header • Entity Header • Entity Body
Message Format • RequestMethod SP URI SP HTTP-Version CRLFGeneral HeaderRequest HeaderEntity HeaderCRLFEntity Body
Message Format • ResponseHTTP-Version SP Status-Code SP Reason-PhraseCRLFGeneral HeaderResponse HeaderEntity HeaderCRLFEntity Body
Message Headers • Name: Valueเช่น Date: Tue, 15 April 1995 07:45:20 GMT • อาจมีได้หลายบรรทัด • ลำดับของฟิล์ไม่สำคัญ • Comments กำหนดได้โดยเขียนภายในวงเล็บ
General Headers • สามารถกำหนดให้เป็นส่วนหนึ่งของ Request หรือ Response ได้ • ประกอบด้วย • Date • Forwarded • Message-ID • MIME-Version
Request Messages • Method • Resource Identifier • Protocol Version
Methods • GETเอกสารส่งไปยัง serverโดยต่อท้ายไปกับ URI ถ้าเป็น CGI จะเก็บในตัวแปร QUERY_STRING • HEAD ต้องการดูคุณสมบัติของเอกสาร โดยไม่ต้องส่งเอกสาร • POSTส่งข้อมูลไปยัง server โดยข้อมูลที่ส่งไปจะอยู่ถัดจาก Hearder ตรวจสอบได้จากตัวแปร CONTENT_LENGTH • PUT : replace doc with data • DELETE : delete doc • LINK • UNLINK
Request Headers • Accept, Accept-Charset, Accept-Encoding, Accept-Language • Authorization • From • If-Modified-Since • Referer • User-Agent • Accept • Accept-Encoding
ตัวอย่าง ส่งข้อมูลด้วยวิธี Post POST/cgi-bin/script.cgiHTTP/1.0 Accept: text/html Accept:video/mpeg User-Agent:Mozilla/2.0(compatibel;MSIE 3.02;Windows95) Content-type:application/x-www-form-urlencoded Content-lenhth:36 เว้น 1 บรรทัด name=casper &password=ghost
Response Messages • Response Headers • Response Body
Response Headers • Protocol Version • Numeric Status Code • Associated Textual Phrase
Status Codes • 1xx - Informational • 2xx - Successful • 3xx - Redirection • 4xx - Client Error • 5xx - Server Error
2xx Status Codes • 200 OK • 201 Created: URL created by POST • 202 Accepted: accepted for later processing • 203 Partial Information: “unofficial” info • 204 No Content: done, but no output
Other Status Codes • 304 Not Modified: response to a conditional GET • 401 Unauthorized: ไม่ได้รับอนุญาตเข้าถึงเอกสารนั้น • 403 Forbidden: มีข้อมูล, แต่ไม่สามารถเข้าถึงได้ • 404 Not Found: ไม่พบเอกสารที่ต้องการ • 500 Internal Error: มีข้อผิดพลาดจากการทำงานของ server เอง
Response Headers • Public • Retry-After • Server • WWW-Authenticate
Entity Headers • Allow • Content-Encoding • Content-Length • Content-Type • Expires • Last-Modified
MIME Types • ใช้สำหรับจำแนกข้อมูล(classify data) • ประกอบด้วย • Type • Subtype • แสดงในรูป : Type/Subtype • เช่น : text/html, image/gif
ตัวอย่าง Response Header HTTP/1.0200OK Date:Thu,31Dec199823:30:00GMT Server:Apache/1.2.5 MINE-version:1.0 LastModified:Mon,7Dec199812:00:05GMT Content-type:Text/html Content-lenhth:4578 เว้น 1 บรรทัด <HTML><HEAD><TITLE>...
HTTP Next Generation • Family of protocols • caching and replication of servers • notification of changes • client/server transport • Replacement of HTTP/1.x, not fix
HTTP-NG Proposal • Multiple, asynchronous requests over a single connection • Server responds in any order or interleaved: “parallel” transfer • Session layer protocol implemented with separate channels for control and data • One data channel for each object. • ASN.1 and PER for describing and encoding requests