Http请求/响应Tcp连接 [英] Http Request/Response Tcp connection

查看:114
本文介绍了Http请求/响应Tcp连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在详细研究http协议,并了解了本教程. 我认为当发出http请求时,将建立一个黑白连接的客户端(浏览器)和服务器之间的TCP连接.在该TCP连接上发送HTTP请求数据,在服务器端解析HTTP请求,并在同一TCP连接上发送HTTP响应.发送响应后,TCP连接终止. 对于下一个http请求,将建立一个新的TCP连接.但是下面的教程说了别的话.我是对还是错?

I was studying http protocol in detail and come across this tutorial. I think when http request is made, a TCP connection is established b/w client(browser) and server. On that TCP connection http request data is sent, on server side http request is parsed and on the same TCP connection http response is sent. After response is sent, TCP connection is terminated. For next http request a new TCP connection will be established. But below tutorial saying something else. Am I right or wrong?

推荐答案

HTTP 是无状态的,不是无连接的.该段是错误的,连接已连接,直到至少将响应发送回调用方.实际上,如果需要完成对同一终结点的多个请求,则相同的连接将被重用.由于使用HTTP/1.1,可以一次发送许多请求,并以相同的顺序等待响应

HTTP is stateless, not connection-less. That paragraph is wrong, the connection is connected until, at least, the response is sent back to the caller. In practice, the same connection is reused if several requests to the same endpoint needs to be done, and since HTTP/1.1 is it possible to send many requests at once and wait for responses in the same order.

这篇关于Http请求/响应Tcp连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆