4, http agreement of the two

URL Brief

Relative URL page from the current

Jump from absolute URL or other page from the current page

HTTPD version <0.9 text> <1.0, method, mime, weak cache> <1.1 persistent connection> <2.0, mime, spdy, cache, method>

HTTPD characteristics: stateless text encoding protocol <telnet, curl, enlinks>

Track user source mechanisms: cookie (heavy cookie, light cookie), session

 

Cookie Category

Cookie working mechanisms: random number that uniquely identifies the user

Light cookie application: data structures stored cookie and session mapping

HTTP transactions: a request and response

Transactional metadata: headers

Entity: entity-body

Detailed HTTP request response packet:

<method> <url> <version>

<header>

...

<header>

Empty 1

2 empty

<entity-body>

 

<version> <status> <reason-phrase>

<header>

...

<header>

Empty 1

2 empty

<entity-body>

 

100 Information

200 OK Success

301 Moved Permantly permanent 302 Found 304 Not Modified temporary conditions

401 WWW-Authenticate challenge authentication 403 Forbidden 404 Not Found do not have permission to access resources not 

500 Internal Server Error internal service error 502 Bad Gateway Bad Gateway

 

Uniform Resource Locator identifies the location of each URL resource URL is a subset of URI

 

wKiom1nJ-RDgjRdhAAA-u68AC_I008.png

wKioL1nJ-NXS1xyJAACC9wLjBC8129.png

 

Relative URL: relative URL of the current page (relative path: starting from the current working directory path)

Absolute URL: used for cross-reference station or the current page (absolute path: a / initial path)

HTTPD version 

wKioL1nJ-bWwnqnDAAAszbo6oXQ354.png

HTTPD characteristics

wKiom1nJ-jXz_ZYOAAAWHLnJ7Ok403.png

Track user source mechanism

wKiom1nJ-oTzb3cHAAAHTu69TLE113.png

Cookie works

wKioL1nJ_W-j4nQ2AADisY5AgIA700.png

Secondary communication: 

服务器 接收随机数(令牌) <-- 客户端  将访问的服务器首次所发的令牌发给服务器,用于标明自己的身份

Cookie分类

wKioL1nJ_knDLRDUAAAlkc-4pAc492.png

Session:<轻cookie:减小隐私信息丢失的可能性>,在服务器端在进程内存中维护Session

wKioL1nKACzjB7cDAAAprAAb4BM891.png

 

HTTP事务 一次httpd请求和响应

事务元数据:(起始行+headers)

实体:entity-body部分

 

HTTP请求响应报文详解

wKioL1nKCjmBW5eAAAAM3N4-Lu8364.png

 

请求报文

wKioL1nKAlPRzSviAAARRu56gy8100.png

响应报文

wKiom1nKAqywVdBHAAAWkJRJ9bg885.png

 

method 客户端告诉服务器做什么

wKiom1nKBaGj_rUIAAAcdYi6Clg457.png

wKioL1nK_hzSRk8zAAB6IST_l6w385.png

 

wKioL1nKBbvhanV6AAAxM7P7-Vs104.png

wKioL1nKBdHyvTomAAA8r275sOE884.png

 

 

status code 服务器告诉客户端结果

reason-phrase  原因短语

wKioL1nKCfnDMJQ7AAA7gHUxIlc298.png

反向代理:将自己扮演为服务端接收请求,支持缓存,拆封报文并重新封装

正向代理:将自己扮演为客户端发起请求

 

重定向

 

条件式请求

wKiom1nKDQDAKVABAAAcrcrqZSY284.png

 

 

用户质询认证

wKioL1nKEJ_RfY8cAABfRT5vde0430.png

 

Forbidden 请求被禁止,IP控制或用户访问控制不通过时

404 用户请求一个不存在的资源 

 

错误网关:

wKiom1nKCyiwOmz-AAArdZbEuwo524.png

 

 

 

headers 请求和响应首部: 标记请求或响应的属性 , 事务交换的元数据信息

负载均衡调度时,可以根据首部调度

1、首部可以有多个

2、首部的格式:Directive: value

 

首部分类

wKioL1nKEmiA_Y_gAAAb_Bob7YQ259.png

 

通用首部

wKioL1nKErSyDWUqAAAxLomZ27M461.png

 

请求首部

自己可接受的特性

 

 

条件式请求首部: 缓存相关

wKiom1nKGCCQ-9_LAAA19DhGWsw154.png

安全请求首部

wKiom1nKGNqAK_99AAAWs2Nbg00161.png

代理请求首部

wKioL1nKGReBaSenAAAK9fBIGgM709.png

 

响应首部

wKioL1nKGe7TdQ02AABKbEoprig846.png

 

实体首部

wKioL1nKIWOiVxRdAABjFnD7AY8390.png

 

示例

General
    Request URL:http://172.16.100.1/          
    Request Method:GET
    Status Code:200 OK
    Remote Address:172.16.100.1:80                   //服务器地址 
Response Headers
view source
    Accept-Ranges:bytes                                          
    Connection:close                                 // 服务器是非持久连接 KeepAlive off
    Content-Encoding:gzip                            // 实体格式:字符集,包含多种语言编码格式
    Content-Length:7725                              // 大小
    Content-Type:text/html; charset=UTF-8            // 类型
    Date:Sat, 09 Sep 2017 12:30:15 GMT               // 请求报文的创建时间
    ETag:"10c-6353-558c0da6c3922"                    // 实体的额外标签,基于标签的条件式请求
    Last-Modified:Sat, 09 Sep 2017 12:30:05 GMT      // 实体最近一次修改的时间    
    Server:Apache/2.2.15 (CentOS)                    // 服务器程序名、版本号
    Vary:Accept-Encoding                             // 服务器查看变化的首部
Request Headers
view source
    The Accept: text / HTML, file application / XHTML + XML, applicat // client acceptable MIME type of 
    the Accept-Encoding: the gzip, the deflate, SDCH              // compression format client pharmaceutically     
    the Accept-the Charset:                                  // character set                
    Accept- language: the CN-ZH, ZH; Q = 0.8                   // client accepted languages encoding format 
    the cache-control: max-Age = 0                          // cache control 
    Connection: Keep-Alive                            //  
    the host: 172.16 . 100.1                                // server host                   
    agent-the user: Mozilla / 5.0                  // user agent
 

 

Guess you like

Origin www.cnblogs.com/liuzhiyun/p/11737193.html