HTTP头是客户端与服务器通信时传递的元信息,包含请求或响应的附加指令。以下是常见HTTP头的分类说明:

请求头(Request Headers)

  • User-Agent
    标识客户端类型,例如浏览器或移动设备。

    User-Agent
    *示例:`User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36`*
  • Content-Type
    指定请求体的数据格式,如 application/jsontext/html

    Content_Type
    *常见值:`application/x-www-form-urlencoded`(表单数据)*
  • Accept-Language
    声明客户端接受的语言偏好,例如 zh-CNen-US

    Accept_Language

响应头(Response Headers)

  • Content-Length
    表示响应体的字节大小,帮助客户端分配缓冲区。

    Content_Length
  • Cache-Control
    控制缓存行为,如 no-cachemax-age=3600

    Cache_Control
  • Set-Cookie
    用于服务器向客户端发送Cookie,例如:

    Set-Cookie: sessionId=abc123; Path=/
    
    Set_Cookie

扩展阅读

如需深入了解HTTP请求方法,可访问 HTTP请求方法详解