HTTPResponse 类
🌐 HTTPResponse class
HTTPResponse 类表示由 Page 类接收的响应。
🌐 The HTTPResponse class represents responses which are received by the Page class.
语法
🌐 Signature
export declare abstract class HTTPResponse
附注
🌐 Remarks
这个类的构造函数被标记为内部。第三方代码不应直接调用构造函数或创建继承 HTTPResponse 类的子类。
🌐 The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the HTTPResponse class.
方法
🌐 Methods
方法 🌐 Method | 修饰符 🌐 Modifiers | 描述 🌐 Description |
|---|---|---|
| buffer() | Promise 解析为带有响应正文的缓冲区。 🌐 Promise which resolves to a buffer with response body. 附注 浏览器可能会根据 HTTP 头或其他启发式方法重新编码缓冲区。如果浏览器未能检测到正确的编码,缓冲区可能会被编码错误。请参阅 https://github.com/puppeteer/puppeteer/issues/6478。 🌐 The buffer might be re-encoded by the browser based on HTTP-headers or other heuristics. If the browser failed to detect the correct encoding, the buffer might be encoded incorrectly. See https://github.com/puppeteer/puppeteer/issues/6478. | |
| content() | Promise 解析为带有响应正文的缓冲区。 🌐 Promise which resolves to a buffer with response body. 附注 浏览器可能会根据 HTTP 头或其他启发式方法重新编码缓冲区。如果浏览器未能检测到正确的编码,缓冲区可能会被编码错误。请参阅 https://github.com/puppeteer/puppeteer/issues/6478。 🌐 The buffer might be re-encoded by the browser based on HTTP-headers or other heuristics. If the browser failed to detect the correct encoding, the buffer might be encoded incorrectly. See https://github.com/puppeteer/puppeteer/issues/6478. | |
| frame() | 一个发起此响应的框架,或者如果导航到错误页面则为 🌐 A Frame that initiated this response, or | |
| fromCache() | 如果响应是从浏览器的磁盘缓存或内存缓存提供的,则为 true。 🌐 True if the response was served from either the browser's disk cache or memory cache. | |
| fromServiceWorker() | 如果响应是由服务工作进程提供的,则为 true。 🌐 True if the response was served by a service worker. | |
| headers() | 一个与响应相关联的 HTTP 头对象。所有头名称都是小写。 🌐 An object with HTTP headers associated with the response. All header names are lower-case. | |
| json() | Promise 解析为响应正文的 JSON 表示形式。 🌐 Promise which resolves to a JSON representation of response body. 附注 如果响应主体无法通过 🌐 This method will throw if the response body is not parsable via | |
| ok() | 如果响应成功(状态范围为 200-299),则为 true。 🌐 True if the response was successful (status in the range 200-299). | |
| remoteAddress() | 用于连接到远程服务器的 IP 地址和端口号。 🌐 The IP address and port number used to connect to the remote server. | |
| request() | 一个匹配的 HTTPRequest 对象。 🌐 A matching HTTPRequest object. | |
| securityDetails() | SecurityDetails 如果响应是通过安全连接接收的,否则为 | |
| status() | 响应的状态代码(例如,200 表示成功)。 🌐 The status code of the response (e.g., 200 for a success). | |
| statusText() | 响应的状态文本(例如,成功时通常为“OK”)。 🌐 The status text of the response (e.g. usually an "OK" for a success). | |
| text() | Promise 解析为响应正文的文本 (utf8) 表示形式。 🌐 Promise which resolves to a text (utf8) representation of response body. 附注 如果内容不是 utf-8 字符串,该方法将抛出异常 🌐 This method will throw if the content is not utf-8 string | |
| timing() | 与响应相关的时间信息。 🌐 Timing information related to the response. | |
| url() | 响应的 URL。 🌐 The URL of the response. |