Requests_Transport_cURL
云策文档标注
概述
本文档介绍了 WordPress 中 Requests 库的 cURL HTTP 传输类 Requests_Transport_cURL,用于通过 cURL 库处理 HTTP 请求。它提供了执行单个和多个请求、处理响应、设置 cURL 句柄等功能。
关键要点
- Requests_Transport_cURL 类基于 cURL 库实现 HTTP 传输,支持 GET 数据格式化、请求头设置和响应处理。
- 核心方法包括 request() 用于执行单个请求,request_multiple() 用于同时发送多个请求,以及 setup_handle() 用于配置 cURL 句柄。
- 其他方法如 stream_body() 和 stream_headers() 用于流式接收数据和头部,test() 用于验证传输有效性。
原文内容
cURL HTTP transport
Methods
| Name | Description |
|---|---|
| Requests_Transport_cURL::__construct | Constructor |
| Requests_Transport_cURL::__destruct | Destructor |
| Requests_Transport_cURL::format_get | Format a URL given GET data |
| Requests_Transport_cURL::get_expect_header | Get the correct “Expect” header for the given request data. |
| Requests_Transport_cURL::get_subrequest_handle | Get the cURL handle for use in a multi-request |
| Requests_Transport_cURL::process_response | Process a response |
| Requests_Transport_cURL::request | Perform a request |
| Requests_Transport_cURL::request_multiple | Send multiple requests simultaneously |
| Requests_Transport_cURL::setup_handle | Setup the cURL handle for the given data |
| Requests_Transport_cURL::stream_body | Collect data as it’s received |
| Requests_Transport_cURL::stream_headers | Collect the headers as they are received |
| Requests_Transport_cURL::test | Whether this transport is valid |