iOS interview about HTTP knowledge Point Basic-01-http

Source: Internet
Author: User

Url
    • URLThe full name is Uniform Resource Locator (Uniform Resource Locator)
    • With 1 URLs, you can find the only 1 resources on the Internet
    • The URL is the address and location of the resource, and every resource on the Internet has a uniqueURL
URL format
    • Basic format: 协议头://主机地址/路径
      • 协议头: Different protocols, which means different resources are found and transmitted.
      • 主机地址: The IP address (domain name) where the resource host is stored
      • 路径: The exact location of the resource in the host

HTTP protocol
    • HTTPThe full name is Hypertext Transfer Protocol , Hypertext Transfer Protocol
    • Specify the data transfer format between the client and server
    • Enables clients and servers to communicate effectively with data
    • HTTPProtocol is the most widely used protocol for network programming

    • Thinking
      • What format data does the client send to the server? The server can read
      • What format of data does the server return to the client? Clients can read
HTTP protocol Features
    • Simple and fast
      • Because the HTTP protocol is simple, HTTP the server has a small program size and fast communication speed.
    • Flexible
      • HTTP allows the transfer of any type of data
    • HTTP 0.9and 1.0 using non-persistent connections
      • This saves transfer time by restricting each connection to only one request, and immediately disconnecting the server when it responds to requests from the client.
    • HTTP 1.1Using Persistent connections
      • You do not have to create a new connection for each Web object, one connection can transfer multiple objects
HTTP Communication Process Request
    • HTTPThe agreement stipulates that a complete 由客户端发给服务器 HTTP 请求 need includes the following:
      • 请求行: Specify 请求方法 , 请求资源路径 andHTTP协议版本
# / 表示访问根目录GET / HTTP/1.1
* `请求头`:对客户端的环境描述、客户端请求的主机地址等信息    * `请求头`中至少包含以下信息
# 客户端要访问的服务器主机地址Host: m.baidu.com
    * `请求头`中还可以包含以下信息
# 客户端的类型,客户端的软件环境User-Agent: iPhone AppleWebKit# 客户端所能接收的数据类型Accept: text/html, */*# 客户端的语言环境Accept-Language: zh-cn# 客户端支持的数据压缩格式Accept-Encoding: gzip# 访问结束后,是否断开连接Connection: Close
* 请求体(可选):客户端发给服务器的具体数据,例如要上传的文件数据
    • Request format
      • At the end of each request message, use the\r\n
      • The end of the last request item is used to \r\n\r\n indicate that the request ended
Response
    • HTTPThe agreement stipulates that: A complete HTTP 响应 contains the following content:
      • Status line: Contains the HTTP protocol version, status code, status English name
# 请求成功HTTP/1.1200 OK# 内容无变化HTTP/1.1304 Not Modified
* 响应头:包含了对服务器的描述、对返回数据的描述
# 服务器的类型Server: Apache/2.4.10 (Unix) PHP/5.5.20# 返回数据的类型Content-Type: text/html# 返回数据的长度660# 响应时间04201519:31:50 GMT# ETag(HASH值,用于检测本地资源和服务器资源是否一致)"294-4e1862f57e7c0"
* 实体内容:服务器返回给客户端的具体二进制数据

iOS interview about HTTP knowledge Point Basic-01-http

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.