mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
2 lines
13 KiB
JavaScript
2 lines
13 KiB
JavaScript
|
/*! For license information please see e5ed1e59.c33c9cb7.js.LICENSE.txt */
|
||
|
"use strict";(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([[64973],{44934:(e,t,r)=>{r.r(t),r.d(t,{assets:()=>c,contentTitle:()=>d,default:()=>o,frontMatter:()=>i,metadata:()=>h,toc:()=>a});var s=r(85893),n=r(11151);const i={sidebar_label:"HTTPRequest"},d="HTTPRequest class",h={id:"api/puppeteer.httprequest",title:"HTTPRequest class",description:"Represents an HTTP request sent by a page.",source:"@site/versioned_docs/version-22.0.0/api/puppeteer.httprequest.md",sourceDirName:"api",slug:"/api/puppeteer.httprequest",permalink:"/api/puppeteer.httprequest",draft:!1,unlisted:!1,tags:[],version:"22.0.0",frontMatter:{sidebar_label:"HTTPRequest"},sidebar:"api",previous:{title:"ElementHandle.waitForSelector",permalink:"/api/puppeteer.elementhandle.waitforselector"},next:{title:"HTTPRequest.abort",permalink:"/api/puppeteer.httprequest.abort"}},c={},a=[{value:"Signature:",id:"signature",level:4},{value:"Remarks",id:"remarks",level:2},{value:"Properties",id:"properties",level:2},{value:"Methods",id:"methods",level:2}];function l(e){const t={a:"a",code:"code",h1:"h1",h2:"h2",h4:"h4",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,n.a)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(t.h1,{id:"httprequest-class",children:"HTTPRequest class"}),"\n",(0,s.jsx)(t.p,{children:"Represents an HTTP request sent by a page."}),"\n",(0,s.jsx)(t.h4,{id:"signature",children:"Signature:"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-typescript",children:"export declare abstract class HTTPRequest\n"})}),"\n",(0,s.jsx)(t.h2,{id:"remarks",children:"Remarks"}),"\n",(0,s.jsxs)(t.p,{children:["Whenever the page sends a request, such as for a network resource, the following events are emitted by Puppeteer's ",(0,s.jsx)(t.code,{children:"page"}),":"]}),"\n",(0,s.jsxs)(t.ul,{children:["\n",(0,s.jsxs)(t.li,{children:[(0,s.jsx)(t.code,{children:"request"}),": emitted when the request is issued by the page. - ",(0,s.jsx)(t.code,{children:"requestfinished"})," - emitted when the response body is downloaded and the request is complete."]}),"\n"]}),"\n",(0,s.jsxs)(t.p,{children:["If request fails at some point, then instead of ",(0,s.jsx)(t.code,{children:"requestfinished"})," event the ",(0,s.jsx)(t.code,{children:"requestfailed"})," event is emitted."]}),"\n",(0,s.jsxs)(t.p,{children:["All of these events provide an instance of ",(0,s.jsx)(t.code,{children:"HTTPRequest"})," representing the request that occurred:"]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{children:"page.on('request', request => ...)\n"})}),"\n",(0,s.jsxs)(t.p,{children:["NOTE: HTTP Error responses, such as 404 or 503, are still successful responses from HTTP standpoint, so request will complete with ",(0,s.jsx)(t.code,{children:"requestfinished"})," event."]}),"\n",(0,s.jsxs)(t.p,{children:["If request gets a 'redirect' response, the request is successfully finished with the ",(0,s.jsx)(t.code,{children:"requestfinished"})," event, and a new request is issued to a redirected url."]}),"\n",(0,s.jsxs)(t.p,{children:["The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the ",(0,s.jsx)(t.code,{children:"HTTPRequest"})," class."]}),"\n",(0,s.jsx)(t.h2,{id:"properties",children:"Properties"}),"\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{children:"Property"}),(0,s.jsx)(t.th,{children:"Modifiers"}),(0,s.jsx)(t.th,{children:"Type"}),(0,s.jsx)(t.th,{children:"Description"})]})}),(0,s.jsx)(t.tbody,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{children:"client"}),(0,s.jsx)(t.td,{children:(0,s.jsx)("code",{children:"readonly"})}),(0,s.jsx)(t.td,{children:(0,s.jsx)(t.a,{href:"/api/puppeteer.cdpsession",children:"CDPSession"})}),(0,s.jsx)(t.td,{children:"Warning! Using this client can break Puppeteer. Use with caution."})]})})]}),"\n",(0,s.jsx)(t.h2,{id:"methods",children:"Methods"}),"\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx
|