puppeteer/assets/js/f426ef8a.b933f685.js

2 lines
15 KiB
JavaScript
Raw Normal View History

/*! For license information please see f426ef8a.b933f685.js.LICENSE.txt */
"use strict";(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([[7101],{74806:(e,t,r)=>{r.r(t),r.d(t,{assets:()=>c,contentTitle:()=>d,default:()=>p,frontMatter:()=>i,metadata:()=>h,toc:()=>l});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/../docs/api/puppeteer.httprequest.md",sourceDirName:"api",slug:"/api/puppeteer.httprequest",permalink:"/next/api/puppeteer.httprequest",draft:!1,unlisted:!1,tags:[],version:"current",frontMatter:{sidebar_label:"HTTPRequest"},sidebar:"api",previous:{title:"ElementHandle.waitForSelector",permalink:"/next/api/puppeteer.elementhandle.waitforselector"},next:{title:"HTTPRequest.abort",permalink:"/next/api/puppeteer.httprequest.abort"}},c={},l=[{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 a(e){const t={a:"a",code:"code",h1:"h1",h2:"h2",h4:"h4",li:"li",p:"p",pre:"pre",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)("table",{children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{children:(0,s.jsx)(t.p,{children:"Property"})}),(0,s.jsx)("th",{children:(0,s.jsx)(t.p,{children:"Modifiers"})}),(0,s.jsx)("th",{children:(0,s.jsx)(t.p,{children:"Type"})}),(0,s.jsx)("th",{children:(0,s.jsx)(t.p,{children:"Description"})})]})}),(0,s.jsx)("tbody",{children:(0,s.jsxs)("tr",{children:[(0,s.jsx)("td",{children:(0,s.jsx)("span",{id:"client",children:"client"})}),(0,s.jsx)("td",{children:(0,s.jsx)(t.p,{children:(0,s.jsx)(t.code,{children:"readonly"})})}),(0,s.jsx)("td",{children:(0,s.jsx)(t.p,{children:(0,s.jsx)(t.a,{href:"/next/api/puppeteer.cdpsession",children:"CDPSession"})})}),(0,s.jsx)("td",{children:(0,s.jsx)(t.p,{children:"Warning! Using this cl