search
HomeBackend DevelopmentPHP Tutorial为你详细解读HTTP请求头的具体含意,解读请求含意_PHP教程

为你详细解读HTTP请求头的具体含意,解读请求含意

当我们打开一个网页时,浏览器要向网站服务器发送一个HTTP请求头,然后网站服务器根据HTTP请求头的内容生成当次请求的内容发送给浏览器。你明白HTTP请求头的具体含意吗?下面一条条的为你详细解读,先看某一次HTTP请求头的具体内容:

  Accept-Language: zh-cn,zh;q=0.5
  Accept-Charset: GB2312,utf-8;q=0.7,*;q=0.7
  Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
  Accept-Encoding: gzip, deflate
  User-Agent: Mozilla/5.0 (compatible; 域名)
  Host: 域名
  Connection: Keep-Alive

 下面根据以上HTTP请求内容的先后顺序一条条的解读:

 

  1. Accept-Language: zh-cn,zh;q=0.5

      意思:浏览器支持的语言分别是中文和简体中文,优先支持简体中文。

      详解:

      Accept-Language表示浏览器所支持的语言类型;

      zh-cn表示简体中文;zh 表示中文;

      q是权重系数,范围 0 =

     

  2.   Accept-Charset: GB2312,utf-8;q=0.7,*;q=0.7

      意思:浏览器支持的字符编码分别是 GB2312、utf-8 和任意字符,优先顺序是 GB2312、utf-8、*。

      详解:

      Accept-Charset告诉 Web 服务器,浏览器可以接受哪些字符编码;

      GB2312是中国国家标准简体中文字符集,全称《信息交换用汉字编码字符集·基本集》,又称GB0,由中国国家标准总局发布,1981年5月1日实施。GB2312 编码通行于中国大陆;新加坡等地也采用此编码。

      utf-8是 Unicode 的一种变长字符编码又称万国码,由 Ken Thompson 于1992年创建,现在已经标准化为 RFC 3629。

      *表示任意字符编码,虽然 q 都是等于 0.7,但明确指定的 GB2312,utf-8 比 * 具有更高的优先级。

     

  3.   Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

      意思:浏览器支持的 MIME 类型分别是 text/html、application/xhtml+xml、application/xml 和 */*,优先顺序是它们从左到右的排列顺序。

      详解:

      Accept表示浏览器支持的 MIME 类型;

      MIME的英文全称是 Multipurpose Internet Mail Extensions(多功能 Internet 邮件扩充服务),它是一种多用途网际邮件扩充协议,在1992年最早应用于电子邮件系统,但后来也应用到浏览器。

      text/html,application/xhtml+xml,application/xml 都是 MIME 类型,也可以称为媒体类型和内容类型,斜杠前面的是 type(类型),斜杠后面的是 subtype(子类型);type 指定大的范围,subtype 是 type 中范围更明确的类型,即大类中的小类。

      Text:用于标准化地表示的文本信息,文本消息可以是多种字符集和或者多种格式的;

      text/html表示 html 文档;

      Application:用于传输应用程序数据或者二进制数据;

      application/xhtml+xml表示 xhtml 文档;

      application/xml表示 xml 文档。

     

  4.   Accept-Encoding: gzip, deflate

      意思:浏览器支持的压缩编码是 gzip 和 deflate。

      详解:

      Accept-Encoding表示浏览器有能力解码的编码类型;

      gzip是 GNU zip 的缩写,它是一个 GNU 自由软件的文件压缩程序,也经常用来表示 gzip 这种文件格式。

      deflate是同时使用了 LZ77 算法与哈夫曼编码(Huffman Coding)的一个无损数据压缩算法。

       User-Agent: Mozilla/5.0 (compatible;域名)

      

  5. 意思:使用的用户代理是 Mozilla/5.0 (compatible; 域名)。

      详解:

      User-Agent(用户代理),简称 UA,它是一个特殊字符串头,使得服务器能够识别客户端使用的操作系统及版本、CPU 类型、浏览器及版本、浏览器渲染引擎、浏览器语言、浏览器插件等。

      Mozilla/5.0:Mozilla 是浏览器名,版本是 5.0;

      compatible(兼容的)表示平台是兼容模式;

     

  6.   Host: 域名

      Host表示请求的服务器网址;

     

  7.   Connection: Keep-Alive

      Connection表示客户端与服务连接类型;

      Keep-Alive表示持久连接;

     

     

    请求头
    Accept:客户机通过这个头,告诉服务器,它支持哪些数据类型
    Accept-Charset::客户机通过这个头,告诉服务器,它支持的编码
    Accept-Encoding: 客户机通过这个头,告诉服务器,支持哪种数据压缩格式
    Accept-Language: 客户机采用的是哪个语言
    Host:客户机通过这个头,告诉服务器,想访问服务器哪台主机
    If-Modified-Since:客户机通过这个头,告诉服务器,数据缓存的时间
    Referer:客户机通过这个头,告诉服务器,客户机是从哪个页面来的(防盗链)
    User-Agent: 说明客户机操作系统信息,以及浏览器信息
    Cookie:客户机通过这个头,可以带点数据给服务器
    Connection

    响应头
    Location:服务器通过这个头告诉浏览器去访问哪个页面,这个头通常配合302状态码使用
    Content-Encoding: 服务器通过这个头告诉浏览器,回送的数据采用的压缩格式
    Content-Length:  服务器通过这个头告诉浏览器,回送的数据的大小
    Content-Type: 服务器通过这个头告诉浏览器,回送数据的类型
    Last-Modified: 服务器通过这个头告诉浏览器,资源的最后修改时间
    Refresh:服务器通过这个头告诉浏览器,定时刷新网页
    Content-Disposition: attachment; filename=aaa.zip:服务器通过这个头告诉浏览器,以下载方式打开数据
    ETag: W/"7777-1242234904000":缓存相关的头,为每一个资源配一个唯一的编号


    Expires: 0 
    Cache-Control: no-cache 
    Pragma: no-cache   这三个头组合使用,让浏览器不要缓存数据

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1068260.htmlTechArticle为你详细解读HTTP请求头的具体含意,解读请求含意 当我们打开一个网页时,浏览器要向网站服务器发送一个HTTP请求头,然后网站服务器根...
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
What is the difference between unset() and session_destroy()?What is the difference between unset() and session_destroy()?May 04, 2025 am 12:19 AM

Thedifferencebetweenunset()andsession_destroy()isthatunset()clearsspecificsessionvariableswhilekeepingthesessionactive,whereassession_destroy()terminatestheentiresession.1)Useunset()toremovespecificsessionvariableswithoutaffectingthesession'soveralls

What is sticky sessions (session affinity) in the context of load balancing?What is sticky sessions (session affinity) in the context of load balancing?May 04, 2025 am 12:16 AM

Stickysessionsensureuserrequestsareroutedtothesameserverforsessiondataconsistency.1)SessionIdentificationassignsuserstoserversusingcookiesorURLmodifications.2)ConsistentRoutingdirectssubsequentrequeststothesameserver.3)LoadBalancingdistributesnewuser

What are the different session save handlers available in PHP?What are the different session save handlers available in PHP?May 04, 2025 am 12:14 AM

PHPoffersvarioussessionsavehandlers:1)Files:Default,simplebutmaybottleneckonhigh-trafficsites.2)Memcached:High-performance,idealforspeed-criticalapplications.3)Redis:SimilartoMemcached,withaddedpersistence.4)Databases:Offerscontrol,usefulforintegrati

What is a session in PHP, and why are they used?What is a session in PHP, and why are they used?May 04, 2025 am 12:12 AM

Session in PHP is a mechanism for saving user data on the server side to maintain state between multiple requests. Specifically, 1) the session is started by the session_start() function, and data is stored and read through the $_SESSION super global array; 2) the session data is stored in the server's temporary files by default, but can be optimized through database or memory storage; 3) the session can be used to realize user login status tracking and shopping cart management functions; 4) Pay attention to the secure transmission and performance optimization of the session to ensure the security and efficiency of the application.

Explain the lifecycle of a PHP session.Explain the lifecycle of a PHP session.May 04, 2025 am 12:04 AM

PHPsessionsstartwithsession_start(),whichgeneratesauniqueIDandcreatesaserverfile;theypersistacrossrequestsandcanbemanuallyendedwithsession_destroy().1)Sessionsbeginwhensession_start()iscalled,creatingauniqueIDandserverfile.2)Theycontinueasdataisloade

What is the difference between absolute and idle session timeouts?What is the difference between absolute and idle session timeouts?May 03, 2025 am 12:21 AM

Absolute session timeout starts at the time of session creation, while an idle session timeout starts at the time of user's no operation. Absolute session timeout is suitable for scenarios where strict control of the session life cycle is required, such as financial applications; idle session timeout is suitable for applications that want users to keep their session active for a long time, such as social media.

What steps would you take if sessions aren't working on your server?What steps would you take if sessions aren't working on your server?May 03, 2025 am 12:19 AM

The server session failure can be solved through the following steps: 1. Check the server configuration to ensure that the session is set correctly. 2. Verify client cookies, confirm that the browser supports it and send it correctly. 3. Check session storage services, such as Redis, to ensure that they are running normally. 4. Review the application code to ensure the correct session logic. Through these steps, conversation problems can be effectively diagnosed and repaired and user experience can be improved.

What is the significance of the session_start() function?What is the significance of the session_start() function?May 03, 2025 am 12:18 AM

session_start()iscrucialinPHPformanagingusersessions.1)Itinitiatesanewsessionifnoneexists,2)resumesanexistingsession,and3)setsasessioncookieforcontinuityacrossrequests,enablingapplicationslikeuserauthenticationandpersonalizedcontent.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function