Tornado 6.5 Documentation
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 6.3 HTTP servers and clients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . implementions of HTTP (HTTPServer and AsyncHTTPClient). • An asynchronous networking library including the classes IOLoop and IOStream, which serve as the building blocks for the HTTP components and can other protocols. The Tornado web framework and HTTP server together offer a full-stack alternative to WSGI. While it is possible to use the Tornado HTTP server as a container for other WSGI frameworks0 码力 | 272 页 | 1.12 MB | 2 月前3Tornado 6.5 Documentation
Prerequisites: Tornado 6.3 requires Python 3.9 or newer. The following optional packages may be useful:pycurl [http://pycurl.io/] is used by the optional tornado.curl_httpclient. Libcurl version 7.22 or higher is required browser HTTP servers and clients tornado.httpserver — Non-blocking HTTP server tornado.httpclient — Asynchronous HTTP client tornado.httputil — Manipulate HTTP headers and URLs tornado.http1connection http1connection – HTTP/1.x client/server implementation Asynchronous networking tornado.ioloop — Main event loop tornado.iostream — Convenient wrappers for non-blocking socketstornado.netutil — Miscellaneous network0 码力 | 437 页 | 405.14 KB | 2 月前3Rust 程序设计语言 简体中文版 1.85.0
一个你无法修复的无效状 态,那么 panic! 往往是合适的。 然而当错误预期会出现时,返回 Result 仍要比调用 panic! 更为合适。这样的例子包括解析器 接收到格式错误的数据,或者 HTTP 请求返回了一个表明触发了限流的状态。在这些例子中, 应该通过返回 Result 来表明失败预期是可能的,而调用者就必须决定该如何处理这个问题。 当你的代码在进行一个使用无效值进行调用时可能将用户置于风险中的操作时,代码应该首先 关键字来等待响应。接着我们调用其 text 方法来获取响应的文本,这里再一次使用 await 关键字等待。这两个步骤都是异步的。 对于 get 来说,我们需要等待服务器发送回其响应的第一部分,这会包含 HTTP 头 (headers)、cookies 等,这部分响应可以独立于响应体发送。特别是在响应体非常大的时候, 全部到达可能需要一些时间。因此我们不得不等待响应 整体 返回,所以 text 方法也是异步。 21-1 所示: 图 21-1: 我们最后将一起分享的项目 如下是构建 web server 的计划: 1. 学习一些 TCP 与 HTTP 知识 2. 在套接字(socket)上监听 TCP 请求 3. 解析少量的 HTTP 请求 4. 创建一个合适的 HTTP 响应 5. 通过线程池改善 server 的吞吐量 在开始之前,我们先提两点说明。首先,这里使用的方法并不是使用 Rust 构建 web0 码力 | 562 页 | 3.23 MB | 9 天前3
共 3 条
- 1