Web and HTTP

本文详细介绍了HTTP协议的工作原理,包括网页对象的构成、HTTP的无状态特性、非持久性与持久性连接的区别,以及POST和GET方法在数据上传中的应用。还涵盖了HTTP响应状态代码的重要性。
摘要由CSDN通过智能技术生成

Web and HTTP First, a review… ▪ web page consists of objects ▪ object can be HTML file, JPEG image, Java applet, audio file,… ▪ web page consists of base HTML-file which includes several referenced objects ▪ each object is addressable by a URL, e.g.,网页有对象组成 网页有基本HTML组成 包括多个引用对象 每个对象都可以通过URL寻址ff86bf8cabbd4fbba97a38d699ffa7e9.pngHTTP 的工作流程 HTTP: hypertext transfer protocol ▪ Web’s application layer protocol ▪ client/server model • client: browser that requests, receives, (using HTTP protocol) and “displays” Web objects • server: Web server sends (using HTTP protocol) objects in response to requests客户端:请求、接收(使用 HTTP 协议)和 "显示 "网络对象的浏览器 - 服务器: 服务器:网络服务器(使用 HTTP 协议)发送对象以响应请求

HTTP overview (continued) uses TCP: ▪ client initiates TCP connection (creates socket) to server, port 80 ▪ server accepts TCP connection from client ▪ HTTP messages (application-layer protocol messages) exchanged between browser (HTTP client) and Web server (HTTP server) ▪ TCP connection closed 1客户机启动与服务器TCP连接创建socket 端口 2服务器接受来自客户机的TCP的连接 3客户端与服务器之间交换HTTP信息 4关闭TCP连接

HTTP is “stateless”无状态 ▪ server maintains no information about past client requests服务器不维护过去客户端请求信息protocols that maintain “ state ” are complex! ▪ past history (state) must be maintained ▪ if server/client crashes, their views of “ state ” may be inconsistent, must be reconciled

HTTP connections non-persistent HTTP ▪ at most one object sent over TCP connection • connection then closed最多一个对象在TCP连接 连接后会关闭 ▪ downloading multiple objects required multiple connections persistent下载多个对象需要多个连接 HTTP ▪ multiple objects can be sent over single TCP connection between client, server客户端和服务器之间的单个TCP连接可以发送多个对象

7f46c75232364ace8429147d3f3d2798.pngNon-persistent HTTP: response time RTT (definition): time for a small packet to travel from client to server and back一个数据包从客户端传输到服务器在返回的时间HTTP response time: ▪ one RTT to initiate TCP connection ▪ one RTT for HTTP request and first few bytes of HTTP response to return ▪ file transmission time ▪ non-persistent HTTP response time = 2RTT+ file transmission time启动 TCP 连接的一个 RTT ▪ HTTP 请求和 HTTP 响应返回的前几个字节的一个 RTT ▪ 文件传输时间 ▪  non-persistent HTTP 响应时间 = 2RTT+ 文件传输时间

Persistent HTTP non-persistent HTTP issues: ▪ requires 2 RTTs per object ▪ OS overhead for each TCP connection ▪ browsers often open parallel TCP connections to fetch referenced objects每个 TCP 连接需要 2 个 RTT ▪ 每个 TCP 连接的操作系统开销 ▪ 浏览器经常打开并行 TCP 连接以获取引用对象 persistent HTTP: ▪ server leaves connection open after sending response ▪ subsequent HTTP messages between same client/server sent over open connection ▪ client sends requests as soon as it encounters a referenced object ▪ as little as one RTT for all the referenced objects 同一客户端/服务器之间的后续 HTTP 消息通过打开的连接发送 ▪ 客户端在遇到引用对象时立即发送请求 ▪ 所有引用对象只需一个 RTT

HTTP request message ▪ two types of HTTP messages: request, response ▪ HTTP request message: • ASCII (human-readable format)9f608cdb4706416c91315d8577031ff3.png

3、HTTP request message: general format HTTP 有两类报文: • 请求报文——从客户向服务器发送请求报文。 • 响应报文——从服务器到客户的回答。 由于 HTTP 是面向正文的(text-oriented),因 此在报文中的每一个字段都是一些 ASCII 码串, 因而每个字段的长度都是不确定的

Method types HTTP/1.0: ▪ GET ▪ POST ▪ HEAD • asks server to leave requested object out of response 要求服务器在响应中忽略请求对象HTTP/1.1: ▪ GET, POST, HEAD ▪ PUT • uploads file in entity body to path specified in URL field将实体主体上文件上传到URL字段中指定路径 ▪ DELETE • deletes file specified in the URL field删除URL字段中指定文件

Uploading form input POST method: • web page often includes form input • input is uploaded to server in entity body网页通常包含表单输入 输入在实体正文中上传到服务器 URL method: • uses GET method • input is uploaded in URL field of request line 使用GET方法 在请求行的URL字段中上传输入内容9310f02767fa42118bc2bee142df1fa1.png

d9b05212f60f4604849bde437c1a2720.png

HTTP response status codes status code appears in 1st line in server-to-client response message.状态代码出现在服务器到客户端响应信息的第一行f7f8c179597542deb61bcb405a6857c5.png

 

  • 19
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值