Updated March 26, 2025
Share:

How to use HTTP Request Header

by Chaknith Bin

An HTTP request header is a piece of metadata sent by a client (such as a web browser or API client) to a server when making an HTTP request. Headers provide additional information about the request, such as authentication details, content type, user agent, and more.

This feature is used when rendering a URL to PDF, allowing you to provide HTTP header information when making the request.

Get started with IronPDF

Start using IronPDF in your project today with a free trial.

First Step:
green arrow pointer


Use HTTP Request Header Example

Before using the HttpRequestHeaders property to set an HTTP request header, first design a proper HTTP request header object. During the rendering process, this header will be included in the URL request sent to the server. As an example, we will use httpbin.org, a website that helps show the headers request.

:path=/static-assets/pdf/content-code-examples/how-to/http-request-header.cs
using IronPdf;
using System.Collections.Generic;

var renderer = new ChromePdfRenderer();
renderer.RenderingOptions.HttpRequestHeaders = new Dictionary<string, string>
{
    { "Authorization", "Bearer test-token-123" }
};

// Render PDF from authenticated page
var pdf = renderer.RenderUrlAsPdf("https://httpbin.org/bearer");
pdf.SaveAs("output.pdf");

Common HTTP Request Headers

  • Authorization: Sends authentication credentials (Bearer token, Basic auth, etc.)
  • Content-Type: Defines the format of the request body (e.g., application/json)
  • Accept: Specifies the expected response format (e.g., text/html, application/json)
  • User-Agent: Identifies the client making the request (browser, API client, etc.)
  • Referer: Indicates the page that linked to the current request
  • Cookie: Sends cookies for session tracking
Chaknith related to Common HTTP Request Headers

Chaknith Bin

Software Engineer

Chaknith is the Sherlock Holmes of developers. It first occurred to him he might have a future in software engineering, when he was doing code challenges for fun. His focus is on IronXL and IronBarcode, but he takes pride in helping customers with every product. Chaknith leverages his knowledge from talking directly with customers, to help further improve the products themselves. His anecdotal feedback goes beyond Jira tickets and supports product development, documentation and marketing, to improve customer’s overall experience.When he isn’t in the office, he can be found learning about machine learning, coding and hiking.