<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/next/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="3"><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/next/api/puppeteer.httprequest"><linkdata-rh="true"rel="alternate"href="https://pptr.dev/next/api/puppeteer.httprequest"hreflang="en"><linkdata-rh="true"rel="alternate"href="https://pptr.dev/next/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_LWe7"id="signature">Signature:<ahref="#signature"class="hash-link"aria-label="Direct link to Signature:"title="Direct link to Signature:"></a></h4>
<h2class="anchor anchorWithStickyNavbar_LWe7"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_LWe7"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><p>client</p></td><td><p><code>readonly</code></p></td><td><p><ahref="/next/api/puppeteer.cdpsession">CDPSession</a></p></td><td><p>Warning! Using this client can break Puppeteer. Use with caution.</p></td></tr></tbody></table>
<h2class="anchor anchorWithStickyNavbar_LWe7"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><p><ahref="/next/api/puppeteer.httprequest.abort">abort(errorCode, priority)</a></p></td><td></td><td><p>Aborts a request.</p></td></tr><tr><td><p><ahref="/next/api/puppeteer.httprequest.aborterrorreason">abortErrorReason()</a></p></td><td></td><td><p>The most recent reason for aborting the request</p></td></tr><tr><td><p><ahref="/next/api/puppeteer.httprequest.continue">continue(overrides, priority)</a></p></td><td></td><td><p>Continues request with optional request overrides.</p></td></tr><tr><td><p><ahref="/next/api/puppeteer.httprequest.continuerequestoverrides">continueRequestOverrides()</a></p></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><p><ahref="/next/api/puppeteer.httprequest.enqueueinterceptaction">enqueueInterceptAction(pendingHandler)</a></p></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><p><ahref="/next/api/puppeteer.httprequest.failure">failure()</a></p></td><td></td><td><p>Access information about the request's failure.</p></td></tr><tr><td><p><ahref="/next/api/puppeteer.httprequest.fetchpostdata">fetchPostData()</a></p></td><td></td><td><p>Fetches the POST data for the request from the browser.</p></td></tr><tr><td><p><ahref="/next/api/puppeteer.httprequest.finalizeinterceptions">finalizeInterceptions()</a></p></td><td></td><td><p>Awaits pending interception handlers and then decides how to fulfill the request interception.</p></td></tr><tr><td><p><ahref="/next/api/puppeteer.httprequest.frame">frame()</a></p></td><td></td><td><p>The frame that initiated the request, or null if navigating to error pages.</p></td></tr><tr><td><p><ahref="/next/api/puppeteer.httprequest.haspostdata">hasPostData()</a></p></td><td></td><td><p>True when the request has POST data. Note that <ahref="/next/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="/next/api/puppeteer.httprequest.fetchpostdata">HTTPRequest.fetchPostData()</a>.</p></td></tr><tr><td><p><ahref="/next/api/puppeteer.httprequest.headers">headers()</a></p></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><p><ahref="/next/api/puppeteer.httprequest.initiator">initiator()</a></p></td><td></td><td><p>The initiator of the request.</p></td></tr><tr><td><p><ahref="/next/api/puppeteer.httprequest.interceptresolutionstate">interceptResolutionState()</a></p></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>, <code>continue</code>, <code>disabled</code>, <code>none</code>, or <code>already-handled</code>.</p></td></tr><tr><td><p><ahref="/next/api/puppeteer.httprequest.isinterceptresolutionhandled">isInterceptResolutionHandled()</a></p></td><td></td><td><p>Is <code>true</code> if the intercept resolution has already been handled, <code>false</code> otherwise.</p></td></tr><tr><td><p><ahref="/next/api/puppeteer.httprequest.isnavigationrequest">isNavigationRequest()</a></p></td><td></td><td><p>True if the request is the driver of the current frame's navigation.</p></td></tr><tr><td><p><ahref="/next/api/puppeteer.httprequest.method">method()</a></p></td><td></td><td><p>The method used (<code>GET</code>, <code>POST</code>, etc.)</p></td></tr><tr><td><p><ahref="/next/api/puppeteer.httprequest.p