• Product Bundles

    DevCraft

    All Telerik .NET tools and Kendo UI JavaScript components in one package. Now enhanced with:

    • NEW: Design Kits for Figma
    • Online Training
    • Document Processing Library
    • Embedded Reporting for web and desktop
    Web
    Kendo UI UI for jQuery UI for Angular UI for React UI for Vue UI for ASP.NET AJAX UI for ASP.NET MVC UI for ASP.NET Core UI for Blazor UI for Silverlight UI for PHP UI for JSP
    Mobile
    UI for .NET MAUI UI for Xamarin
    Document Management
    Telerik Document Processing
    Desktop
    UI for .NET MAUI UI for WinUI UI for WinForms UI for WPF UI for UWP
    Reporting & Mocking
    Telerik Reporting Telerik Report Server Telerik JustMock
    Automated Testing
    Test Studio Test Studio Dev Edition
    CMS
    Sitefinity
    UI/UX Design
    Unite UX
    Debugging
    Fiddler Fiddler Everywhere Fiddler Classic Fiddler Jam FiddlerCap FiddlerCore
    Extended Reality
    UI for Unity XR
    Free Tools
    JustAssembly JustDecompile VB.NET to C# Converter Testing Framework
    View all products
  • Overview
    • jQuery
    • Angular
    • React
    • Vue
  • Demos
    • What's New
    • Roadmap
    • Release History
  • Docs & Support
  • Pricing
  • Search
  • Shopping cart
    • Account Overview
    • Your Licenses
    • Support Center
    • Forum Profile
    • Payment Methods
    • Edit Profile
    • Log out
  • Login
  • Contact Us
  • Try now

Class HTTPHeaders

Base class for RequestHeaders and ResponseHeaders

Inheritance
System.Object
HTTPHeaders
HTTPRequestHeaders
HTTPResponseHeaders
Namespace: Fiddler
Assembly: FiddlerCore.dll

Syntax

public abstract class HTTPHeaders : Object

Constructors

HTTPHeaders()

Declaration
protected HTTPHeaders()

Fields

_HeaderEncoding

Text encoding to be used when converting this header object to/from a byte array

Declaration
protected Encoding _HeaderEncoding
Field Value
System.Text.Encoding

HTTPVersion

HTTP version (e.g. HTTP/1.1)

Declaration
[CodeDescription("HTTP version (e.g. HTTP/1.1).")]
public string HTTPVersion
Field Value
System.String

storage

Storage for individual HTTPHeaderItems in this header collection NB: Using a list is important, as order can matter

Declaration
protected List<HTTPHeaderItem> storage
Field Value
System.Collections.Generic.List<HTTPHeaderItem>

Properties

Item[Int32]

Indexer property. Returns HTTPHeaderItem by index. Throws Exception if index out of bounds

Declaration
[CodeDescription("Indexer property. Returns HTTPHeaderItem by index.")]
public HTTPHeaderItem this[int iHeaderNumber] { get; set; }
Parameters
System.Int32 iHeaderNumber

Property Value
HTTPHeaderItem

Item[String]

Gets or sets the value of a header. In the case of Gets, the value of the first header of that name is returned. If the header does not exist, returns null. In the case of Sets, the value of the first header of that name is updated.
If the header does not exist, it is added.

Declaration
[CodeDescription("Indexer property. Gets or sets the value of a header. In the case of Gets, the value of the FIRST header of that name is returned.\nIf the header does not exist, returns null.\nIn the case of Sets, the value of the FIRST header of that name is updated.\nIf the header does not exist, it is added.")]
public string this[string HeaderName] { get; set; }
Parameters
System.String HeaderName

Property Value
System.String

Methods

Add(String, String)

Adds a new header containing the specified name and value.

Declaration
[CodeDescription("Add a new header containing the specified name and value.")]
public HTTPHeaderItem Add(string sHeaderName, string sValue)
Parameters
System.String sHeaderName

Name of the header to add.

System.String sValue

Value of the header.

Returns
HTTPHeaderItem

Returns the newly-created HTTPHeaderItem.

Add(String, String, Boolean)

Adds a new header containing the specified name and value and sensitive flag.

Declaration
[CodeDescription("Add a new header containing the specified name and value.")]
public HTTPHeaderItem Add(string sHeaderName, string sValue, bool bSensitive)
Parameters
System.String sHeaderName

Name of the header to add.

System.String sValue

Value of the header.

System.Boolean bSensitive

HTTP2 specific - does the header contain sensitive information.

Returns
HTTPHeaderItem

Returns the newly-created HTTPHeaderItem.

AddPseudoHeader(String, String)

Adds a new pseudo header containing the specified name and value. If header already was added, it will replace the previous value

Declaration
public HTTPHeaderItem AddPseudoHeader(string sHeaderName, string sValue)
Parameters
System.String sHeaderName

Name of the pseudo header to add.

System.String sValue

Value of the pseudo header.

Returns
HTTPHeaderItem

Returns the newly-created HTTPHeaderItem.

AddRange(IEnumerable<HTTPHeaderItem>)

Adds one or more headers

Declaration
public void AddRange(IEnumerable<HTTPHeaderItem> collHIs)
Parameters
System.Collections.Generic.IEnumerable<HTTPHeaderItem> collHIs

AllValues(String)

Returns all values of the named header in a single string, delimited by commas

Declaration
public string AllValues(string sHeaderName)
Parameters
System.String sHeaderName

Header

Returns
System.String

Each, Header's, Value

AssignFromString(String)

Parses a string and assigns the headers parsed to this object

Declaration
public abstract bool AssignFromString(string sHeaders)
Parameters
System.String sHeaders

The header string

Returns
System.Boolean

TRUE if the operation succeeded, false otherwise

ByteCount()

Get byte count of this HTTP header instance when exported to a HTTP/1.1 headers string

Declaration
public virtual int ByteCount()
Returns
System.Int32

Byte Count

Count()

Number of HTTP headers

Declaration
[CodeDescription("Returns an integer representing the number of headers.")]
public int Count()
Returns
System.Int32

Number of HTTP headers

CountOf(String)

Returns the count of instances of the named header

Declaration
public int CountOf(string sHeaderName)
Parameters
System.String sHeaderName

Header name

Returns
System.Int32

Count of instances of the named header

EscapeHeader(String, Boolean)

Escape HTTP2 header names/values

Declaration
protected static string EscapeHeader(string header, bool isName = false)
Parameters
System.String header

The header name or value

System.Boolean isName

True if escaping header name

Returns
System.String

Escaped name or value

Exists(String)

Determines if the Headers collection contains a header of the specified name, with any value.

Declaration
[CodeDescription("Returns true if the Headers collection contains a header of the specified (case-insensitive) name.")]
public bool Exists(string sHeaderName)
Parameters
System.String sHeaderName

The name of the header to check. (case insensitive)

Returns
System.Boolean

True, if the header exists.

ExistsAndContains(String, String)

Determines if the Headers collection contains one or more headers of the specified name, and sHeaderValue is part of one of those Headers' value.

Declaration
[CodeDescription("Returns true if the collection contains a header of the specified (case-insensitive) name, and sHeaderValue (case-insensitive) is part of the Header's value.")]
public bool ExistsAndContains(string sHeaderName, string sHeaderValue)
Parameters
System.String sHeaderName

The name of the header to check. (case insensitive)

System.String sHeaderValue

The partial header value. (case insensitive)

Returns
System.Boolean

True if the header is found and the value case-insensitively contains the parameter

ExistsAndEquals(String, String, Boolean)

Determines if the Headers collection contains a header of the specified name, and sHeaderValue=Header's value. Similar to a case-insensitive version of: headers[sHeaderName]==sHeaderValue, although it checks all instances of the named header.

Declaration
[CodeDescription("Returns true if the collection contains a header of the specified (case-insensitive) name, with value sHeaderValue (case-insensitive).")]
public bool ExistsAndEquals(string sHeaderName, string sHeaderValue, bool isUrl = false)
Parameters
System.String sHeaderName

The name of the header to check. (case insensitive)

System.String sHeaderValue

The full header value. (case insensitive)

System.Boolean isUrl

If true, compare the header values as URLs and if false - do a case insensitive string comparison

Returns
System.Boolean

True if the header is found and the value case-insensitively matches the parameter

ExistsAny(IEnumerable<String>)

Determines if the Headers collection contains any header from the specified list, with any value.

Declaration
[CodeDescription("Returns true if the Headers collection contains a header of the specified (case-insensitive) name.")]
public bool ExistsAny(IEnumerable<string> sHeaderNames)
Parameters
System.Collections.Generic.IEnumerable<System.String> sHeaderNames

list of headers

Returns
System.Boolean

True, if any named header exists.

FilterByHeaderName(String[])

Filter all header items that have different header name from the given

Declaration
public void FilterByHeaderName(string[] headerNames)
Parameters
System.String[] headerNames

FindAll(String)

Returns all instances of the named header

Declaration
public List<HTTPHeaderItem> FindAll(string sHeaderName)
Parameters
System.String sHeaderName

Header name

Returns
System.Collections.Generic.List<HTTPHeaderItem>

List of instances of the named header

FreeReaderLock()

Frrees the Reader Lock. Executed after you finish enumerating the Storage collection.

Declaration
protected void FreeReaderLock()

FreeWriterLock()

If you get the Writer lock, Free it ASAP or you're going to hang or deadlock the Session

Declaration
protected void FreeWriterLock()

FromHeadersFrame(BasePipe, ArraySegment<Byte>, UInt32, Boolean)

Read a data stream and extract HTTP/2 header frame(s) from it

Declaration
protected static List<HeaderField> FromHeadersFrame(BasePipe pipe, ArraySegment<byte> dataStream, uint streamId, bool useNewDecoder = false)
Parameters
BasePipe pipe

The data pipe (used for HTTP2 settings and decoding header data)

System.ArraySegment<System.Byte> dataStream

Array containing the data (request/response)

System.UInt32 streamId

The HTTP/2 stream ID

System.Boolean useNewDecoder

If true, a new HPACK decoder instance will be used (to prevent polluting the default decoder table).

Returns
System.Collections.Generic.List<Http2.Hpack.HeaderField>

Array of "key: value" string objects

GetEnumerator()

Enumerator for HTTPHeader storage collection

Declaration
public IEnumerator GetEnumerator()
Returns
System.Collections.IEnumerator

Enumerator

GetReaderLock()

Get the Reader Lock if you plan to enumerate the Storage collection.

Declaration
protected void GetReaderLock()

GetTokenValue(String, String)

Returns the Value from a token in the header. Correctly handles double-quoted strings. Requires semicolon for delimiting tokens Limitation: FAILS if semicolon is in token's value, even if quoted. FAILS in the case of crazy headers, e.g. Header: Blah="SoughtToken=Blah" SoughtToken=MissedMe

We really need a "proper" header parser

Declaration
[CodeDescription("Returns a string representing the value of the named token within the named header.")]
public string GetTokenValue(string sHeaderName, string sTokenName)
Parameters
System.String sHeaderName

Name of the header

System.String sTokenName

Name of the token

Returns
System.String

Value of the token if present; otherwise, null

GetWriterLock()

Get the Writer Lock if you plan to change the Storage collection. NB: You only need this lock if you plan to change the collection itself; you can party on the items in the collection if you like without locking.

Declaration
protected void GetWriterLock()

Remove(HTTPHeaderItem)

Removes a HTTPHeader item from the collection

Declaration
public void Remove(HTTPHeaderItem oRemove)
Parameters
HTTPHeaderItem oRemove

The HTTPHeader item to be removed

Remove(String)

Removes all headers from the header collection which have the specified name.

Declaration
[CodeDescription("Removes ALL headers from the header collection which have the specified (case-insensitive) name.")]
public void Remove(string sHeaderName)
Parameters
System.String sHeaderName

The name of the header to remove. (case insensitive)

RemoveAll()

Removes all HTTPHeader items from the collection

Declaration
public void RemoveAll()

RemoveRange(String[])

Removes all headers from the header collection which have the specified names.

Declaration
[CodeDescription("Removes ALL headers from the header collection which have the specified (case-insensitive) names.")]
public void RemoveRange(string[] arrToRemove)
Parameters
System.String[] arrToRemove

Array of names of headers to remove. (case insensitive)

RenameHeaderItems(String, String)

Renames all headers in the header collection which have the specified name.

Declaration
[CodeDescription("Renames ALL headers in the header collection which have the specified (case-insensitive) name.")]
public bool RenameHeaderItems(string sOldHeaderName, string sNewHeaderName)
Parameters
System.String sOldHeaderName

The name of the header to rename. (case insensitive)

System.String sNewHeaderName

The new name for the header.

Returns
System.Boolean

True if one or more replacements were made.

SortAscByKeyAndValue()

Sort all header items in ascending order by key and then by value

Declaration
public void SortAscByKeyAndValue()

ToArray()

Copies the Headers to a new array. Prefer this method over the enumerator to avoid cross-thread problems.

Declaration
public HTTPHeaderItem[] ToArray()
Returns
HTTPHeaderItem[]

An array containing HTTPHeaderItems

Getting Started
  • Try Now
Community
  • Forums
  • Blogs
  • Feedback Portal

Copyright © 2019 Progress Software Corporation and/or its subsidiaries or affiliates.
All Rights Reserved.

Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks for appropriate markings.