<titledata-rh="true">HTTPRequest class | Puppeteer</title><metadata-rh="true"name="viewport"content="width=device-width,initial-scale=1"><metadata-rh="true"name="twitter:card"content="summary_large_image"><metadata-rh="true"property="og:url"content="https://pptr.dev/api/puppeteer.httprequest"><metadata-rh="true"property="og:locale"content="en"><metadata-rh="true"name="docsearch:language"content="en"><metadata-rh="true"name="docsearch:counter"content="2"><metadata-rh="true"property="og:title"content="HTTPRequest class | Puppeteer"><metadata-rh="true"name="description"content="Represents an HTTP request sent by a page."><metadata-rh="true"property="og:description"content="Represents an HTTP request sent by a page."><linkdata-rh="true"rel="icon"href="/img/favicon.ico"><linkdata-rh="true"rel="canonical"href="https://pptr.dev/api/puppeteer.httprequest"><linkdata-rh="true"rel="alternate"href="https://pptr.dev/api/puppeteer.httprequest"hreflang="en"><linkdata-rh="true"rel="alternate"href="https://pptr.dev/api/puppeteer.httprequest"hreflang="x-default"><linkdata-rh="true"rel="preconnect"href="https://DVKY664LG7-dsn.algolia.net"crossorigin="anonymous"><linkrel="search"type="application/opensearchdescription+xml"title="Puppeteer"href="/opensearch.xml">
<h4class="anchor anchorWithStickyNavbar_FNw8"id="signature">Signature:<ahref="#signature"class="hash-link"aria-label="Direct link to Signature:"title="Direct link to Signature:"></a></h4>
<h2class="anchor anchorWithStickyNavbar_FNw8"id="remarks">Remarks<ahref="#remarks"class="hash-link"aria-label="Direct link to Remarks"title="Direct link to Remarks"></a></h2>
<p>Whenever the page sends a request, such as for a network resource, the following events are emitted by Puppeteer's <code>page</code>:</p>
<ul>
<li><code>request</code>: emitted when the request is issued by the page. - <code>requestfinished</code> - emitted when the response body is downloaded and the request is complete.</li>
</ul>
<p>If request fails at some point, then instead of <code>requestfinished</code> event the <code>requestfailed</code> event is emitted.</p>
<p>All of these events provide an instance of <code>HTTPRequest</code> representing the request that occurred:</p>
<p>NOTE: HTTP Error responses, such as 404 or 503, are still successful responses from HTTP standpoint, so request will complete with <code>requestfinished</code> event.</p>
<p>If request gets a 'redirect' response, the request is successfully finished with the <code>requestfinished</code> event, and a new request is issued to a redirected url.</p>
<p>The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the <code>HTTPRequest</code> class.</p>
<h2class="anchor anchorWithStickyNavbar_FNw8"id="properties">Properties<ahref="#properties"class="hash-link"aria-label="Direct link to Properties"title="Direct link to Properties"></a></h2>
<table><thead><tr><th><p>Property</p></th><th><p>Modifiers</p></th><th><p>Type</p></th><th><p>Description</p></th></tr></thead><tbody><tr><td><spanid="client">client</span></td><td><p><code>readonly</code></p></td><td><p><ahref="/api/puppeteer.cdpsession">CDPSession</a></p></td><td><p><strong><em>(Experimental)</em></strong> Warning! Using this client can break Puppeteer. Use with caution.</p></td></tr></tbody></table>
<h2class="anchor anchorWithStickyNavbar_FNw8"id="methods">Methods<ahref="#methods"class="hash-link"aria-label="Direct link to Methods"title="Direct link to Methods"></a></h2>
<table><thead><tr><th><p>Method</p></th><th><p>Modifiers</p></th><th><p>Description</p></th></tr></thead><tbody><tr><td><spanid="abort"><ahref="/api/puppeteer.httprequest.abort">abort(errorCode, priority)</a></span></td><td></td><td><p>Aborts a request.</p><p><strong>Remarks:</strong></p><p>To use this, request interception should be enabled with <ahref="/api/puppeteer.page.setrequestinterception">Page.setRequestInterception()</a>. If it is not enabled, this method will throw an exception immediately.</p></td></tr><tr><td><spanid="aborterrorreason"><ahref="/api/puppeteer.httprequest.aborterrorreason">abortErrorReason()</a></span></td><td></td><td><p>The most recent reason for aborting the request</p></td></tr><tr><td><spanid="continue"><ahref="/api/puppeteer.httprequest.continue">continue(overrides, priority)</a></span></td><td></td><td><p>Continues request with optional request overrides.</p><p><strong>Remarks:</strong></p><p>To use this, request interception should be enabled with <ahref="/api/puppeteer.page.setrequestinterception">Page.setRequestInterception()</a>.</p><p>Exception is immediately thrown if the request interception is not enabled.</p></td></tr><tr><td><spanid="continuerequestoverrides"><ahref="/api/puppeteer.httprequest.continuerequestoverrides">continueRequestOverrides()</a></span></td><td></td><td><p>The <code>ContinueRequestOverrides</code> that will be used if the interception is allowed to continue (ie, <code>abort()</code> and <code>respond()</code> aren't called).</p></td></tr><tr><td><spanid="enqueueinterceptaction"><ahref="/api/puppeteer.httprequest.enqueueinterceptaction">enqueueInterceptAction(pendingHandler)</a></span></td><td></td><td><p>Adds an async request handler to the processing queue. Deferred handlers are not guaranteed to execute in any particular order, but they are guaranteed to resolve before the request interception is finalized.</p></td></tr><tr><td><spanid="failure"><ahref="/api/puppeteer.httprequest.failure">failure()</a></span></td><td></td><td><p>Access information about the request's failure.</p><p><strong>Remarks:</strong></p></td></tr><tr><td><spanid="fetchpostdata"><ahref="/api/puppeteer.httprequest.fetchpostdata">fetchPostData()</a></span></td><td></td><td><p>Fetches the POST data for the request from the browser.</p></td></tr><tr><td><spanid="finalizeinterceptions"><ahref="/api/puppeteer.httprequest.finalizeinterceptions">finalizeInterceptions()</a></span></td><td></td><td><p>Awaits pending interception handlers and then decides how to fulfill the request interception.</p></td></tr><tr><td><spanid="frame"><ahref="/api/puppeteer.httprequest.frame">frame()</a></span></td><td></td><td><p>The frame that initiated the request, or null if navigating to error pages.</p></td></tr><tr><td><spanid="haspostdata"><ahref="/api/puppeteer.httprequest.haspostdata">hasPostData()</a></span></td><td></td><td><p>True when the request has POST data. Note that <ahref="/api/puppeteer.httprequest.postdata">HTTPRequest.postData()</a> might still be undefined when this flag is true when the data is too long or not readily available in the decoded form. In that case, use <ahref="/api/puppeteer.httprequest.fetchpostdata">HTTPRequest.fetchPostData()</a>.</p></td></tr><tr><td><spanid="headers"><ahref="/api/puppeteer.httprequest.headers">headers()</a></span></td><td></td><td><p>An object with HTTP headers associated with the request. All header names are lower-case.</p></td></tr><tr><td><spanid="initiator"><ahref="/api/puppeteer.httprequest.initiator">initiator()</a></span></td><td></td><td><p>The initiator of the request.</p></td></tr><tr><td><spanid="interceptresolutionstate"><ahref="/api/puppeteer.httprequest.interceptresolutionstate">interceptResolutionState()</a></span></td><td></td><td><p>An InterceptResolutionState object describing the current resolution action and priority.</p><p>InterceptResolutionState contains: action: InterceptResolutionAction priority?: number</p><p>InterceptResolutionAction is one of: <code>abort</code>, <code>respond</code>,