mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
2 lines
17 KiB
JavaScript
2 lines
17 KiB
JavaScript
|
/*! For license information please see f426ef8a.6f2ea82d.js.LICENSE.txt */
|
||
|
"use strict";(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([[7101],{74806:(e,t,s)=>{s.r(t),s.d(t,{assets:()=>c,contentTitle:()=>d,default:()=>p,frontMatter:()=>i,metadata:()=>h,toc:()=>l});var r=s(85893),n=s(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",em:"em",h1:"h1",h2:"h2",h4:"h4",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,n.a)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(t.h1,{id:"httprequest-class",children:"HTTPRequest class"}),"\n",(0,r.jsx)(t.p,{children:"Represents an HTTP request sent by a page."}),"\n",(0,r.jsx)(t.h4,{id:"signature",children:"Signature:"}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-typescript",children:"export declare abstract class HTTPRequest\n"})}),"\n",(0,r.jsx)(t.h2,{id:"remarks",children:"Remarks"}),"\n",(0,r.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,r.jsx)(t.code,{children:"page"}),":"]}),"\n",(0,r.jsxs)(t.ul,{children:["\n",(0,r.jsxs)(t.li,{children:[(0,r.jsx)(t.code,{children:"request"}),": emitted when the request is issued by the page. - ",(0,r.jsx)(t.code,{children:"requestfinished"})," - emitted when the response body is downloaded and the request is complete."]}),"\n"]}),"\n",(0,r.jsxs)(t.p,{children:["If request fails at some point, then instead of ",(0,r.jsx)(t.code,{children:"requestfinished"})," event the ",(0,r.jsx)(t.code,{children:"requestfailed"})," event is emitted."]}),"\n",(0,r.jsxs)(t.p,{children:["All of these events provide an instance of ",(0,r.jsx)(t.code,{children:"HTTPRequest"})," representing the request that occurred:"]}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{children:"page.on('request', request => ...)\n"})}),"\n",(0,r.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,r.jsx)(t.code,{children:"requestfinished"})," event."]}),"\n",(0,r.jsxs)(t.p,{children:["If request gets a 'redirect' response, the request is successfully finished with the ",(0,r.jsx)(t.code,{children:"requestfinished"})," event, and a new request is issued to a redirected url."]}),"\n",(0,r.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,r.jsx)(t.code,{children:"HTTPRequest"})," class."]}),"\n",(0,r.jsx)(t.h2,{id:"properties",children:"Properties"}),"\n",(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:(0,r.jsx)(t.p,{children:"Property"})}),(0,r.jsx)("th",{children:(0,r.jsx)(t.p,{children:"Modifiers"})}),(0,r.jsx)("th",{children:(0,r.jsx)(t.p,{children:"Type"})}),(0,r.jsx)("th",{children:(0,r.jsx)(t.p,{children:"Description"})})]})}),(0,r.jsx)("tbody",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"client",children:"client"})}),(0,r.jsx)("td",{children:(0,r.jsx)(t.p,{children:(0,r.jsx)(t.code,{children:"readonly"})})}),(0,r.jsx)("td",{children:(0,r.jsx)(t.p,{children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.cdpsession",children:"CDPSession"})})}),(0,r.jsx)("td",{children:(0,r.jsxs)(t.p,{childre
|