HTTP and Flask Basics -HTTP介绍

Hypertext Transfer Protocol (HTTP) is a protocol that provides a standardized way for computers to communicate with each other. It has been the foundation for data communication over the internet since 1990 and is integral to understanding how client-server communication functions.


Features
  • Connectionless: When a request is sent, the client opens the connection; once a response is received, the client closes the connection. The client and server only maintain a connection during the response and request. Future responses are made on a new connection. In other words, Client opens one connection for each request, which is closed once the server responds.
  • Stateless: There is no dependency between successive requests. In other words, no information is required from one request in order to process a subsequent request.
  • Not Sessionless: Utilizing headers and cookies, sessions can be created to allow each HTTP request to share the same context. HTTP requests can share the same context using tools such as cookies.
  • Media Independent: Any type of data can be sent over HTTP as long as both the client and server know how to handle the data format. For example, JSON format. HTTP requests can include any type of data as long as both the server and client know how to handle that data type.

HTTP Elements
  • Uniform Resource Identifier (URIs)
  • Messages: Requests and Responses
  • Status Codes (e.g. 404 NOT FOUND)

Elements

  • Universal Resource Identifiers (URIs): An example URI is http://www.example.com/tasks/term=homework. It has certain components:
    • Scheme: specifies the protocol used to access the resource. HTTP or HTTPS. In the above example, http
    • Host: specifies the host that holds the resources. In the above example, www.example.com
    • Path: specifies the specific resource being requested. In the above example, /tasks
    • Query: an optional component, the query string provides information the resource can use for some purpose such as a search parameter. In the above example, /term=homework

URI vs URL
You may be unsure what the difference is between a URI (Universal Resource Identifier) and a URL (Universal Resource Locator).

The term URI can refer to any identifier for a resource - for example, it could be either the name of a resource or the address (since both the name and address are identifiers of that resource).
In contrast, URL only refers to the location of a resource. In other words, it only ever refers to an address.

Thus, URI could refer to a name or an address, while URL only refers to an address. URLs are a specific type of URL that is used to locate a resource on the internet when a client makes a request to a server.


What is the difference between URI and URL?

What is the difference between a URI, a URL, and a URN?

An overview of HTTP

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值