Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

Use Playwright’s APIRequestContext.head(url) method to send an HTTP HEAD request. It returns an APIResponse, so you can inspect the status and headers without asking the server to return the resource representation. In JavaScript or TypeScript, the basic call is await request.head('https://example.com/resource'). Playwright follows redirects by default; set maxRedirects: 0 if you need to inspect the response without following them.

Send a HEAD request in JavaScript or TypeScript

For an API-only request, create a standalone request context with Playwright. This does not require launching a browser: APIRequestContext can make HTTP requests on its own.

  1. Install Playwright: npm install playwright.

  2. Save the following as head-request.mjs.

  3. Run it with node head-request.mjs.

import { request } from 'playwright';

const api = await request.newContext();

try {
  const response = await api.head('https://example.com/resource', {
    timeout: 30_000,
  });

  console.log('Status:', response.status());
  console.log('OK:', response.ok());
  console.log('Headers:', response.headers());
  console.log('Content type:', response.headers()['content-type'] ?? '(not provided)');
} finally {
  await api.dispose();
}

The try/finally ensures the standalone context is disposed even if the request throws. The response’s status() and headers() methods are useful for metadata checks. A HEAD response does not provide the representation body, so this method is not a way to download or inspect the page content.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use the test runner’s request context

In a Playwright Test, use the request context attached to the page or browser context when you want the API request to share that browser context’s cookies. The associated page.request and browserContext.request refer to the same request context for that browser context.

#1 Best Overall
Sale
Nineplus Wireless USB WiFi Adapter for PC - 1300Mbps Dual 5Dbi Antennas 5G/2.4G WiFi Adapter for Desktop PC Laptop Windows11/10/7, Wireless Adapters for Desktop Computer Network Adapters
  • Fast 1300Mbps USB WiFi Adapter - Nineplus wifi adapter provides long-range and stable wifi connections,Upgrade your desktop or laptop wifi Technology with our AC1300Mbps usb wireless Adapter. Whether your desktop pc's wifi usb is malfunctioning or you’re looking to upgrade to faster dual-band 5GHz and 2.4GHz speeds, this pc wifi adapter is the ideal choice. It’s a budget-friendly way to extend your device’s life and experience the benefits of modern WiFi technology
  • Dual-band 5.8GHz and 2.4GHz Bands - 5.8Ghz wifi Connection speed up to 867Mbps,2.4GHz 400Mbps,With these upgraded speeds, web surfing, gaming, and streaming online meeting is much more enjoyable without buffering or interruptions,Experience the High Wi-Fi speed of our AC1300Mbps wifi dongle delivers faster internet speeds and stronger, more reliable signal penetration over long distances. It's a high-speed dual-band wifi usb adapter for pc and easy for the modern user.
  • Two 5dBi High Gain Wifi Antenna – The high gain antenna of the desktop wifi adapter greatly enhances the reception and transmission of WiFi signal strengths.Equipped with dual high-gain pc wifi antenna, our wifi dongle for desktop pc ensures accurate capture of WiFi signals, providing a stable and strong connection even at greater distances, ideal for overcoming poor signal issues in bedrooms. This computer wifi adapter, wifi card, and usb wifi antenna extend your coverage.
  • Super Speed USB 3.0 - wifi adapter for desktop pc Connect speeds Up to 10x faster than USB 2.0 USB, Super USB3.0 delivers faster data transfer, a more reliable network connection, and improved compatibility for wifi adapter for pc. It fully supports the high-speed demands of AC1300 wireless adapter, ensuring peak performance. Plus, it's backward compatible with standard USB 2.0 ports for added flexibility.usb wifi adapter for desktop pc 3.0
  • Compatibility Systems: This Wi-Fi usb adapter is compatible with Windows11/10/8.1/8/7/XP,not supports Mac OS or Chromebook or Linux. Most Windows 11/10 systems will automatically detect and install the drivers. If the system does not detect the driver, you will need to download it from our website. For Windows 7, you will need to manually install the driver for this wifi card.or you go to the website online-setup support,we do online-setup for you.
import { test, expect } from '@playwright/test';

test('checks resource headers', async ({ page }) => {
  const response = await page.request.head('https://example.com/resource');

  expect(response.ok()).toBeTruthy();
  console.log(response.headers());
});

This example uses the Playwright Test fixture rather than creating and disposing a separate context. Choose the standalone context when you want cookie storage isolated from a browser session.

Choose the right request context

Context Cookie behavior Use it when
page.request or browserContext.request Shares the browser context’s cookie jar. Response cookies can also update that jar. The request should use the session associated with the page or browser context.
playwright.request.newContext() Uses isolated cookie storage. You want a standalone API request or do not want browser-session cookies carried over.

Cookie sharing concerns the request context’s cookie jar; it does not turn a HEAD request into a browser navigation. Use the context that matches the authentication and session behavior you need.

Read the response and handle status codes

head() resolves to an APIResponse. Check the status explicitly if the outcome matters to your program. By default, failOnStatusCode is false, so an HTTP error status is returned as a response rather than automatically throwing only because the status is unsuccessful.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Sale
TP-Link USB to Ethernet Adapter,Support Nintendo Switch,1Gbps,Plug and Play
  • 𝐇𝐢𝐠𝐡-𝐒𝐩𝐞𝐞𝐝 𝐔𝐒𝐁 𝐄𝐭𝐡𝐞𝐫𝐧𝐞𝐭 𝐀𝐝𝐚𝐩𝐭𝐞𝐫 - UE306 is a USB 3.0 Type-A to RJ45 Ethernet adapter that adds a reliable wired network port to your laptop, tablet, or Ultrabook. It delivers fast and stable 10/100/1000 Mbps wired connections to your computer or tablet via a router or network switch, making it ideal for file transfers, HD video streaming, online gaming, and video conferencing.
  • 𝐔𝐒𝐁 𝟑.𝟎 𝐟𝐨𝐫 𝐅𝐚𝐬𝐭𝐞𝐫, 𝐌𝐨𝐫𝐞 𝐒𝐭𝐚𝐛𝐥𝐞 𝐃𝐚𝐭𝐚 𝐓𝐫𝐚𝐧𝐬𝐟𝐞𝐫𝐬- Powered via USB 3.0, this adapter provides high-speed Gigabit Ethernet without the need for external power(10/100/1000Mbps). Backward compatible with USB 2.0/1.1, it ensures reliable performance across a wide range of devices.
  • 𝐒𝐮𝐩𝐩𝐨𝐫𝐭𝐬 𝐍𝐢𝐧𝐭𝐞𝐧𝐝𝐨 𝐒𝐰𝐢𝐭𝐜𝐡- Easily connect your Nintendo Switch to a wired network for faster downloads and a more stable online gaming experience compared to Wi-Fi.
  • 𝐏𝐥𝐮𝐠 𝐚𝐧𝐝 𝐏𝐥𝐚𝐲- No driver required for Nintendo Switch, Windows 11/10/8.1/8, and Linux. Simply connect and enjoy instant wired internet access without complicated setup.
  • 𝐁𝐫𝐨𝐚𝐝 𝐃𝐞𝐯𝐢𝐜𝐞 𝐂𝐨𝐦𝐩𝐚𝐭𝐢𝐛𝐢𝐥𝐢𝐭𝐲- Supports Nintendo Switch, PCs, laptops, Ultrabooks, tablets, and other USB-powered web devices; works with network equipment including modems, routers, and switches.
const response = await api.head('https://example.com/resource');

if (!response.ok()) {
  console.error(`HEAD request returned HTTP ${response.status()}`);
} else {
  console.log(response.headers());
}

A successful call does not guarantee that every desired header is present. The server determines whether it supports HEAD and what status and headers it returns. If you need the representation itself, use an appropriate GET request instead.

Inspect selected headers

JavaScript’s response.headers() returns a header object with lowercase names. For example, response.headers()['content-type'] reads the content-type header if the server supplied it. Header availability depends on the response; use a fallback rather than assuming a particular header exists.

Control redirects, timeout, and request options

Playwright follows redirects automatically by default. The documented maximum is 20 redirects. Set maxRedirects to zero to disable following, or set a different limit when your request needs one.

Rank #3
TP-Link USB WiFi 6 Adapter for Desktop PC -AX1800 Dual Band WiFi Adapter
  • 𝐅𝐚𝐬𝐭, 𝐅𝐥𝐞𝐱𝐢𝐛𝐥𝐞 𝐖𝐢-𝐅𝐢 𝟔 - Delivers smooth dual-band connectivity, with 5 GHz for streaming and gaming and 2.4 GHz for longer-range browsing, downloads, and everyday use. Performance varies by conditions, distance to devices, & obstacles such as walls.
  • 𝐈𝐧𝐬𝐭𝐚𝐧𝐭 𝐔𝐩𝐠𝐫𝐚𝐝𝐞 𝐟𝐨𝐫 𝐎𝐮𝐭𝐝𝐚𝐭𝐞𝐝 𝐖𝐢-𝐅𝐢- Whether your current Wi-Fi card is outdated or malfunctioning, this powerful USB adapter is a cost-effective way to revive and modernize your device for the digital age. Enhance your productivity and entertainment experience instantly.
  • 𝐆𝐫𝐞𝐚𝐭𝐞𝐫 𝐂𝐨𝐯𝐞𝐫𝐚𝐠𝐞 𝐚𝐧𝐝 𝐂𝐨𝐧𝐧𝐞𝐜𝐭𝐢𝐨𝐧 𝐒𝐭𝐚𝐛𝐢𝐥𝐢𝐭𝐲 - Equipped with 2× high-gain dual-band antennas and advanced beamforming technology, the TX30U Plus ensures stronger signal reception and wider Wi-Fi coverage. Even in complex layouts or through walls, it delivers reliable and consistent connectivity—ideal for homes, apartments, and office environments. Perfect for streaming, gaming, and video conferencing across rooms or floors.
  • 𝐎𝐮𝐫 𝐂𝐲𝐛𝐞𝐫𝐬𝐞𝐜𝐮𝐫𝐢𝐭𝐲 𝐂𝐨𝐦𝐦𝐢𝐭𝐦𝐞𝐧𝐭 - TP-Link is a signatory of the U.S. Cybersecurity and Infrastructure Security Agency’s (CISA) Secure-by-Design pledge. This device is designed, built, and maintained, with advanced security as a core requirement.
  • 𝐄𝐚𝐬𝐲 𝐭𝐨 𝐔𝐬𝐞 – 1. Easy Installation - Installs quickly with our preloaded internal driver for seamless connectivity. 2. Adjust and Pack with Ease - Optimizes signal with adjustable antennas and folds compactly for easy storage.
const response = await api.head('https://example.com/resource', {
  maxRedirects: 0,
  timeout: 10_000,
  headers: {
    'x-check-source': 'playwright',
  },
  params: {
    version: 'current',
  },
});

console.log(response.status(), response.headers());

Request timeouts are measured in milliseconds and default to 30,000 ms. Set timeout: 0 to disable the timeout; for most automated checks, a finite timeout is easier to operate because it prevents a stalled endpoint from holding up the job indefinitely. The example’s 10,000 ms is an explicit choice, not a Playwright default.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

headers adds request headers, and params supplies query parameters. If you disable redirects, the response describes the request’s current response rather than a followed destination. If you allow them, Playwright follows them up to the configured limit.

Python spelling and example

In Python, the method is api_request_context.head(url). The same decision applies: use the request context associated with a browser context for shared cookies, or create an isolated context when you want separate cookie storage. This standalone script makes a request, prints its status and headers, and disposes of its request context.

Rank #4
TP-Link AC600 USB WiFi Adapter for Desktop PC - USB Wireless Adapter for PC
  • 𝐋𝐨𝐧𝐠 𝐑𝐚𝐧𝐠𝐞 𝐀𝐝𝐚𝐩𝐭𝐞𝐫 – This compact USB Wi-Fi adapter provides long-range and lag-free connections wherever you are. Upgrade your PCs or laptops to 802.11ac standards which are three times faster than wireless N speeds.
  • 𝐒𝐦𝐨𝐨𝐭𝐡 𝐋𝐚𝐠 𝐅𝐫𝐞𝐞 𝐂𝐨𝐧𝐧𝐞𝐜𝐭𝐢𝐨𝐧𝐬 – Get Wi-Fi speeds up to 200 Mbps on the 2.4 GHz band and up to 433 Mbps on the 5 GHz band for upgraded web surfing, gaming, and streaming. Performance varies by conditions, distance to devices, and obstacles such as walls.
  • 𝐃𝐮𝐚𝐥-𝐛𝐚𝐧𝐝 𝟐.𝟒 𝐆𝐇𝐳 𝐚𝐧𝐝 𝟓 𝐆𝐇𝐳 𝐁𝐚𝐧𝐝𝐬 – Dual-bands provide flexible connectivity, giving your devices access to the latest routers for faster speeds and extended range. Wireless Security - WEP, WPA/WPA2, WPA-PSK/WPA2-PSK
  • 𝟓𝐝𝐁𝐢 𝐇𝐢𝐠𝐡 𝐆𝐚𝐢𝐧 𝐀𝐧𝐭𝐞𝐧𝐧𝐚 – The high gain antenna of the Archer T2U Plus greatly enhances the reception and transmission of WiFi signal strengths.
  • 𝐀𝐝𝐣𝐮𝐬𝐭𝐚𝐛𝐥𝐞, 𝐌𝐮𝐥𝐭𝐢-𝐃𝐢𝐫𝐞𝐜𝐭𝐢𝐨𝐧𝐚𝐥 𝐀𝐧𝐭𝐞𝐧𝐧𝐚: Rotate the multi-directional antenna to face your router to improve your experience and performance
import asyncio
from playwright.async_api import async_playwright

async def main():
    async with async_playwright() as playwright:
        api = await playwright.request.new_context()
        try:
            response = await api.head(
                "https://example.com/resource",
                timeout=30_000,
            )
            print("Status:", response.status)
            print("OK:", response.ok)
            print("Headers:", await response.all_headers())
        finally:
            await api.dispose()

asyncio.run(main())

Install the Python package with pip install playwright. This API-only example does not launch a browser. If your request needs browser-context cookies, use that browser context’s request API rather than a new isolated context. See the official Playwright APIRequestContext reference for the JavaScript and Python APIs and their options.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot common HEAD request problems

The server returns an unsuccessful status

Read response.status() instead of assuming that a resolved promise means the resource check succeeded. Since failOnStatusCode defaults to false, handle the returned status in your code. A server may reject HEAD or return a status that reflects its own endpoint behavior; the Playwright method cannot make an unsupported endpoint accept the request.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The request is using the wrong cookies

A standalone context has isolated cookie storage. If the target relies on a browser session, make the request through page.request or browserContext.request for that browser context. Conversely, create a standalone request context when session cookies should not be reused.

Best Value
Sale
TP-Link WiFi 6 PCIe WiFi Card for Desktop PC- AX3000 Dual Band Network Card
  • 𝐍𝐞𝐱𝐭 𝐆𝐞𝐧 𝐖𝐢𝐅𝐈 𝟔 - Reach incredible speeds up to 2.4 Gbps (2402 Mbps in 5 GHz or 574 Mbps on 2.4 GHz) with ultra-low latency and uninterrupted connectivity using Wi-Fi 6 technologies¹
  • 𝐌𝐢𝐧𝐢𝐦𝐢𝐳𝐞𝐝 𝐋𝐚𝐠 𝐟𝐨𝐫 𝐘𝐨𝐮𝐫 𝐏𝐂 - The networking card is equipped with OFDMA and MU-MIMO technology to reduce lag so you can enjoy ultra-responsive real-time gaming, or an immersive VR experience on even the busiest networks
  • 𝐁𝐫𝐨𝐚𝐝𝐞𝐫 𝐑𝐚𝐧𝐠𝐞 - 2 powerful signal-boost, high-gain antennas greatly inrease range for a smoother online gaming experience in further away distances
  • 𝐁𝐥𝐮𝐞𝐭𝐨𝐨𝐭𝐡 𝟓.𝟐 𝐟𝐨𝐫 𝐆𝐫𝐞𝐚𝐭𝐞𝐫 𝐒𝐩𝐞𝐞𝐝 𝐚𝐧𝐝 𝐑𝐚𝐧𝐠𝐞 - Equipped with the latest Bluetooth technology, Archer TX55E achieves 2x faster speeds and 4x broader coverage compared to Bluetooth 4.2 so you can connect your favorite devices such as game controllers, headphones, and keyboards for the ultimate setup.²
  • 𝐂𝐮𝐭𝐭𝐢𝐧𝐠 𝐄𝐝𝐠𝐞 𝐖𝐏𝐀𝟑 - Protector your network with the latest WPA3 security protocol so your information transmitted via the wireless adapter is secure from hackers³

The request follows a redirect unexpectedly

Redirect following is enabled by default. Set maxRedirects: 0 to stop at the first response, or choose a limit that fits the endpoint’s redirect chain. A redirect limit is separate from the request timeout.

The request takes too long or times out

The default timeout is 30 seconds. Set a suitable finite timeout for the endpoint and the job’s latency budget. Although timeout: 0 disables the timeout, that also removes this bound, so use it only when unbounded waiting is intentional.

A header or body you expected is missing

HEAD requests ask for response metadata without the representation body. Inspect the headers actually returned and account for absent values. If the task requires reading the resource, use GET rather than trying to extract a body from HEAD.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Or skip the browser setup

If your real goal is a website screenshot rather than checking HTTP headers, ScreenshotNeo is a separate option: it is a website screenshot API and MCP server from Yorker Media, not a HEAD-request tool. This one GET call returns a screenshot; see the ScreenshotNeo API documentation for its parameters and response details.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

ScreenshotNeo accepts cookie or consent banners as a visitor and removes 60+ known consent platforms, newsletter popups and chat widgets before capture; each step can be turned off. Bot checks, blank pages, timeouts, failed loads and cache hits are not billed, and response headers say which page verdict applied and whether the request was billed. Its MCP server offers take_screenshot, get_page_info and capture_pdf for Claude, Cursor and other MCP clients. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots.

Sign up for 1,000 free screenshots a month, with no card required.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.