Requests_Session
云策文档标注
概述
Requests_Session 是 WordPress 中用于处理持久 HTTP 请求和默认参数的会话处理器。它允许设置默认选项和基础 URL,并支持合并请求数据,简化了重复 HTTP 操作的管理。
关键要点
- 提供持久会话支持,可设置默认请求参数(如共享 cookie jar)和基础 URL。
- 包含多种 HTTP 方法接口,如 GET、POST、PUT、DELETE、HEAD、PATCH,以及批量请求功能。
- 支持属性管理(__get、__set、__isset、__unset)和请求数据合并(merge_request)。
原文内容
Session handler for persistent requests and default parameters
Description
Allows various options to be set as default values, and merges both the options and URL properties together. A base URL can be set for all requests, with all subrequests resolved from this. Base options can be set (including a shared cookie jar), then overridden for individual requests.
Methods
| Name | Description |
|---|---|
| Requests_Session::__construct | Create a new session |
| Requests_Session::__get | Get a property’s value |
| Requests_Session::__isset | Remove a property’s value |
| Requests_Session::__set | Set a property’s value |
| Requests_Session::__unset | Remove a property’s value |
| Requests_Session::delete | Send a DELETE request |
| Requests_Session::get | Send a GET request |
| Requests_Session::head | Send a HEAD request |
| Requests_Session::merge_request | Merge a request’s data with the default data |
| Requests_Session::patch | Send a PATCH request |
| Requests_Session::post | Send a POST request |
| Requests_Session::put | Send a PUT request |
| Requests_Session::request | Main interface for HTTP requests |
| Requests_Session::request_multiple | Send multiple HTTP requests simultaneously |