HTTP基础知识汇总

这篇具有很好参考价值的文章主要介绍了HTTP基础知识汇总。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

云原生(Cloud Native)的兴起,面向服务架构(Service-Oriented Architecture,SOA)、微服务(Microservice)容器(Container)等相关概念与技术正在逐渐影响CAx(CAD/CAE/CAM)软件的架构设计与开发。

云原生CAx软件中,首先需要把系统按照功能划分成不同的服务单元然后再根据业务流程完成各种服务的集成(Enterprise Application IntegrationEAI)。Web ServicesMicroservice是将应用程序转换成服务的常用方法,而这些技术实际上大多数都是以HTTP为基础的。

因此,非常有必要对HTTP的概念、原理等基础知识进行总结,以期能够更好的进行云原生CAx软件的设计与开发。

注1:限于研究水平,分析难免不当,欢迎批评指正

注2:文章内容会不定期更新

一、HTTP基础

HTTP(HyperText Transfer Protocol, 超文本传输协议)是一种采用"请求-应答"通信模式、运行在TCP协议之上的应用层协议,早期主要应用于Web服务器与客户端之间HTML数据传输。

Ref. from Hypertext Transfer Protocol -- HTTP/1.1

The Hypertext Transfer Protocol (HTTP) is an application-level protocol for distributed, collaborative, hypermedia information systems. It is a generic, stateless, protocol which can be used for many tasks beyond its use for hypertext, such as name servers and distributed object management systems, through extension of its request methods, error codes and headers. A feature of HTTP is the typing and negotiation of data representation, allowing systems to be built independently of the data being transferred.

  1.1 HTTP工作原理

HTTP采用请求-应答通信模式,一般用于B/S架构中HTTP Client与HTTP Server之间的网络通信。

Ref. from HTTP/1.1 Overall Operation

The HTTP protocol is a request/response protocol. A client sends a request to the server in the form of a request method, URI, and protocol version, followed by a MIME-like message containing request modifiers, client information, and possible body content over a connection with a server. The server responds with a status line, including the message's protocol version and a success or error code, followed by a MIME-like message containing server information, entity metainformation, and possible entity-body content.

One or more intermediaries are present in the request/response chain. There are three common forms of intermediary: proxy, gateway, and tunnel.A proxy is a forwarding agent, receiving requests for a URI in its absolute form, rewriting all or part of the message, and forwarding the reformatted request toward the server identified by the URI. A gateway is a receiving agent, acting as a layer above some other server(s) and, if necessary, translating the requests to the underlying server's protocol. A tunnel acts as a relay point between two connections without changing the messages; tunnels are used when the communication needs to pass through an intermediary (such as a firewall) even when the intermediary cannot understand the contents of the messages.

首先,HTTP Client(通常是浏览器)创建一个到HTTP Server指定端口(默认为80端口)的TCP连接,然后HTTP Client向HTTP Server发送HTTP请求报文。

HTTP server收到HTTP请求报文之后,完成HTTP请求报文数据报文解析,执行对应的业务逻辑,然后将状态码、处理结果等写入到一个HTTP响应报文,并将该HTTP响应报文返还给HTTP Client。

HTTP Client收到HTTP响应报文之后,根据返还状态、处理结果等完成显示、数据存储等工作。

  1.2 HTTP数据报文

HTTP请求报文由请求行、请求头部、空行、请求数据等四个部分组成。

HTTP基础知识汇总

 HTTP响应报文由状态行、消息报头、空行、响应正文等四个部分组成。

HTTP基础知识汇总

  1.3 浏览器架构

HTTP基础知识汇总
Chromium's high-level architecture

  1.4 HTTP会话保持

HTTP协议本身是无状态的。对于浏览器,一般一个连接处理一个请求,完成一次“请求-应答”之后一般会断开连接。对于服务器,请求彼此之间是独立的,服务器无法知道请求之间的关联。

Ref. from HTTP/1.1 Connections

A significant difference between HTTP/1.1 and earlier versions of HTTP is that persistent connections are the default behavior of any HTTP connection. That is, unless otherwise indicated, the client SHOULD assume that the server will maintain a persistent connection, even after error responses from the server.

Cookie、Session和Token是常用的会话保持技术。

关于此部分的内容请关注笔者博文:云原生CAx软件:多租户的认证

二、实现与衍生

  2.1 Boost

Module Description Scenario
Beast Portable HTTP, WebSocket, and network operations using only C++11 and Boost.Asio

  2.2 Qt

Module Description Scenario
Qt Network

Classes to make network programming easier and more portable.

Currently HTTP, FTP and local file URLs are supported for uploading and downloading.

封装了套接字,也实现了HTTP、FTP等常见网络协议
Qt WebSockets Provides WebSocket communication compliant with RFC 6455.  It provides an implementation for the WebSocket protocol, which is offered by IETF (Internet Engineering Task Force) as a better alternative for bidirectional communication using the existing web infrastructure. 服务端主动向客户端推送数据
Qt WebChannel Provides access to QObject or QML objects from HTML clients for seamless integration of Qt applications with HTML/JavaScript clients. 基于Qt的Server应用
Qt WebKit The QtWebKit module provides a web browser engine as well as classes to render and interact with web content 在Qt5中,被Qt WebEngine替换
Qt WebEngine Classes and functions for embedding web content in applications using the Chromium browser project. 作为Qt WebEngine替换者,在应用中显示Web内容
Qt WebView Displays web content in a QML application by using APIs native to the platform, without the need to include a full web browser stack. 在QML程序中显示Web内容
Qt for WebAssembly A platform target to compile Qt applications for the web browsers using WebAssembly. 将Qt应用嵌入到Web页面

  2.3 MIME

  2.4 DIME

  2.5 WebSocket

Ref. from The WebSocket Protocol

The WebSocket Protocol enables two-way communication between a client running untrusted code in a controlled environment to a remote host that has opted-in to communications from that code.  The security model used for this is the origin-based security model commonly used by web browsers.  The protocol consists of an opening handshake followed by basic message framing, layered over TCP.  The goal of this technology is to provide a mechanism for browser-based applications that need two-way communication with servers that does not rely on opening multiple HTTP connections.

The protocol has two parts: a handshake and the data transfer.

The handshake from the client looks as follows:

GET /chat HTTP/1.1
Host: server.example.com
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==
Origin: http://example.com
Sec-WebSocket-Protocol: chat, superchat
Sec-WebSocket-Version: 13

The handshake from the server looks as follows:

HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=
Sec-WebSocket-Protocol: chat

After a successful handshake, clients and servers transfer data back and forth in conceptual units referred to in this specification as "messages".  On the wire, a message is composed of one or more frames. The WebSocket message does not necessarily correspond to a particular network layer framing, as a fragmented message may be coalesced or split by an intermediary.

0                   1                   2                   3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-------+-+-------------+-------------------------------+
|F|R|R|R| opcode|M| Payload len |    Extended payload length    |
|I|S|S|S|  (4)  |A|     (7)     |             (16/64)           |
|N|V|V|V|       |S|             |   (if payload len==126/127)   |
| |1|2|3|       |K|             |                               |
+-+-+-+-+-------+-+-------------+ - - - - - - - - - - - - - - - +
|     Extended payload length continued, if payload len == 127  |
+ - - - - - - - - - - - - - - - +-------------------------------+
|                               |Masking-key, if MASK set to 1  |
+-------------------------------+-------------------------------+
| Masking-key (continued)       |          Payload Data         |
+-------------------------------- - - - - - - - - - - - - - - - +
:                     Payload Data continued ...                :
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
|                     Payload Data continued ...                |
+---------------------------------------------------------------+

  2.6 Web Services 

  2.7 ESB

  2.8 API GateWay

  2.9 WebGL and Three.js

参考文献

罗军舟. TCP/IP协议及网络编程技术. 清华大学, 2004.

Joseph Ingeno. Handbook of Software Architecture.

顾宁. Web Services原理与研发实践. 机械工业出版社, 2005.

网络资料

大型CAx(CAD/CAE/CAM)工业软件开发中的关键组件https://blog.csdn.net/qq_26221775/article/details/123193318?spm=1001.2014.3001.5501

云原生CAx软件:多租户的认证https://blog.csdn.net/qq_26221775/article/details/130441983?spm=1001.2014.3001.5502

Hypertext Transfer Protocol -- HTTP/1.0 https://datatracker.ietf.org/doc/html/rfc1945

Hypertext Transfer Protocol -- HTTP/1.1https://datatracker.ietf.org/doc/html/rfc2616

HTTP State Management Mechanism draft-abarth-cookie-07https://datatracker.ietf.org/doc/html/draft-abarth-cookie-07

JSON Web Tokenhttps://datatracker.ietf.org/doc/html/rfc7519

Google Chromehttps://www.google.cn/intl/en_uk/chrome/

The Chromium Projectshttps://www.chromium.org/Home/

gSOAPhttps://www.genivia.com/

Boosthttps://www.boost.org/doc/libs/1_80_0/

Qt5 All Moduleshttps://doc.qt.io/qt-5/qtmodules.html

Qt5 Porting Guidehttps://doc.qt.io/qt-5/portingguide.html

Qt4.8 WebKithttps://doc.qt.io/archives/qt-4.8/qtwebkit-module.html

WebSockethttps://datatracker.ietf.org/doc/html/rfc6455

Qt for WebAssemblyhttps://doc.qt.io/qt-5/wasm.html

Spring Web Serviceshttps://spring.io/projects/spring-ws

OpenESBhttp://www.open-esb.net/

Pattern: API Gateway / Backends for Frontends Contexthttps://microservices.io/patterns/apigateway.html

Spring Cloud Gatewayhttps://spring.io/projects/spring-cloud-gateway

Netflix Zuulhttps://github.com/Netflix/zuul

Nginx http://nginx.org/en/index.html

Konghttps://github.com/Kong/kong

WebGL https://www.khronos.org/webgl/

Three.js https://threejs.org/文章来源地址https://www.toymoban.com/news/detail-425891.html

到了这里,关于HTTP基础知识汇总的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • ElasticSearch基础知识汇总

    Elasticsearch是一个基于Lucene的搜索服务器。它提供了 一个分布式多用户能力的全文搜索引擎 , 基于RESTful web接口 。Elasticsearch是用Java语言开发的,并作为Apache许可条款下的开放源码发布,是一种流行的企业级搜索引擎。Elasticsearch用于云计算中,能够达到实时搜索,稳定,可靠

    2024年02月11日
    浏览(32)
  • Zookeeper 基础知识汇总

    中文教程:https://www.docs4dev.com/docs/zh/zookeeper/r3.5.6/reference/zookeeperOver.html ZooKeeper 是⼀种分布式协调服务,⽤于管理⼤型主机。在分布式环境中协调和管理服务是 ⼀个复杂的过程。ZooKeeper 通过其简单的架构和 API 解决了这个问题。ZooKeeper 允许开 发⼈员专注于核⼼应⽤程序逻辑

    2024年02月08日
    浏览(45)
  • Python基础知识汇总(集合)

    Python中的集合用于保存不重复元素,分为可变集合(set)和不可变集合(frozenset)两种。 本文主要是讲可变集合set的常用操作,包括创建集合、集合中添加元素和删除元素、集合的交集、并集和差集运算等。 set集合是无序可变序列,集合的所有元素都放在一对大括号“{}”中

    2023年04月26日
    浏览(27)
  • Matlab基础知识汇总(小白速成)

    1.矩阵运算符 运算 符号 说明 具体表现实现 转置 A.\\\' 矩阵转置 共轭转置 A\\\' 复矩阵共轭转置,当A为实数矩阵时等价于A.\\\' 加减 A+B、A-B 矩阵元素之间相互进行加减 数与矩阵加减 K+A、K-A 数与矩阵的加减操作 数乘以矩阵 k*A 数对矩阵中的每个元素进行相乘 矩阵相乘 A * B A.*B 乘法运

    2024年02月08日
    浏览(28)
  • 信息与网络安全基础知识汇总

    1.网络信息安全基本概念 信息安全 :是指信息网络中的硬件、软件及其系统中的数据受到保护,不受偶然的或者恶意的原因而遭到破坏、更改、泄露、否认等,系统连续可靠正常的运行,信息服务不中断。 密码学: 是结合数学、计算机科学、电子与通信等学科于一体的交叉

    2024年02月03日
    浏览(30)
  • 计算机网络——基础知识汇总(八)

    个人名片: 🦁作者简介:一名喜欢分享和记录学习的在校大学生 🐯个人主页:妄北y 🐧个人QQ:2061314755 🐻个人邮箱:2061314755@qq.com 🦉个人WeChat:Vir2021GKBS 🐼 本文由妄北y原创,首发CSDN 🎊🎊🎊 🐨座右铭:大多数人想要改造这个世界,但却罕有人想改造自己。 专栏导航

    2024年02月03日
    浏览(45)
  • 计算机基础知识点汇总

    1、指令是指示计算机执行某种操作的命令,包括操作码和地址码两部分。 2、目前常见的指令系统有复杂指令系统(CISC)和精简指令系统(RISC)。 3、计算机的工作过程:取指令、分析指令、执行指令。 4、未配置任何软件的计算机叫裸机,注意不是指安装过操作系统的计算

    2024年02月10日
    浏览(36)
  • 数电模电基础知识学习笔记汇总

    文章目录: 数电和模电的关系 一:模电学习笔记 二:数电学习笔记 三:福利 1.NI Multisim14.0电路仿真软件的下载安装 2.进制转换 3.电路常用公式 4.好的参考笔记  4.1 笔记  3.1.1 模电 3.1.1 数电 4.2 网站 5.八股文 来源:一周搞(不)定数电模电全集,电子基础知识 11小时 模电基

    2024年02月15日
    浏览(44)
  • SQL Server数据库基础知识汇总

    目录 目录 一、数据库概念 1.1 什么是数据库 1.2 为什么用数据库 1.3 数据库的发展历史 1.4 数据库分类 1.5 DBMS数据库管理系统 二、 SQL(Structured Query Language) 2.1  定义 2.2  SQL分类 2.3 SQL与T-SQL 三、SqlServer下载与安装 四、数据库表各类操作 1 创建数据库登录用户 2 使用DCL赋予数据

    2023年04月09日
    浏览(40)
  • 第四章 云原生架构之Kubernetes基础知识

    ​ Kubernetes是一个可移植、可扩展的开源平台,用于管理容器化的工作负载和服务,简称 K8S。 K8S的本质是一组服务器集群,可以在对应服务器集群的每个节点上运行程序,来对节点中的容器进行管理 。类似Master-Work方式,每个服务器上安装特定的k8s组件,就可以形成集群,然

    2024年02月17日
    浏览(37)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包