Web and HTTP

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

 

相关推荐

最近更新

  1. TCP协议是安全的吗?

    2024-03-22 05:24:02       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-03-22 05:24:02       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-03-22 05:24:02       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-03-22 05:24:02       18 阅读

热门阅读

  1. ollama -linux部署

    2024-03-22 05:24:02       21 阅读
  2. Linux 常用命令 chgrp

    2024-03-22 05:24:02       21 阅读
  3. MyBatis面试简答题

    2024-03-22 05:24:02       18 阅读
  4. 使用Linq的Distinct方法

    2024-03-22 05:24:02       18 阅读
  5. Linux:协议定制以及序列化和反序列化

    2024-03-22 05:24:02       17 阅读
  6. C语言学习笔记day11

    2024-03-22 05:24:02       19 阅读
  7. 网络编程模拟面试题总结, sqlite3的c语言调用,

    2024-03-22 05:24:02       19 阅读