ClassHTTPHeaders
Base class for RequestHeaders and ResponseHeaders
Definition
Namespace:Fiddler
Assembly:FiddlerCore.dll
Syntax:
public abstract class HTTPHeaders
Inheritance: objectHTTPHeaders
Derived Classes:
Inherited Members
Constructors
HTTPHeaders()
Declaration
protected HTTPHeaders()
Fields
HTTPVersion
HTTP version (e.g. HTTP/1.1)
Declaration
[CodeDescription("HTTP version (e.g. HTTP/1.1).")]
public string HTTPVersion
Field Value
_HeaderEncoding
Text encoding to be used when converting this header object to/from a byte array
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
Properties
this[int]
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
iHeaderNumber
Property Value
this[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
HeaderName
Property Value
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
sHeaderName
Name of the header to add.
sValue
Value of the header.
Returns
Returns the newly-created HTTPHeaderItem.
Add(string, string, bool)
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
sHeaderName
Name of the header to add.
sValue
Value of the header.
bSensitive
HTTP2 specific - does the header contain sensitive information.
Returns
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
sHeaderName
Name of the pseudo header to add.
sValue
Value of the pseudo header.
Returns
Returns the newly-created HTTPHeaderItem.
AddRange(IEnumerable<HTTPHeaderItem>)
Adds one or more headers
Declaration
public void AddRange(IEnumerable<HTTPHeaderItem> collHIs)
Parameters
collHIs
AllValues(string)
Returns all values of the named header in a single string, delimited by commas
AssignFromString(string)
Parses a string and assigns the headers parsed to this object
ByteCount()
Get byte count of this HTTP header instance when exported to a HTTP/1.1 headers string
Count()
Number of HTTP headers
Declaration
[CodeDescription("Returns an integer representing the number of headers.")]
public int Count()
Returns
Number of HTTP headers
CountOf(string)
Returns the count of instances of the named header
EscapeHeader(string, bool)
Escape HTTP2 header names/values
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
sHeaderName
The name of the header to check. (case insensitive)
Returns
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
sHeaderName
The name of the header to check. (case insensitive)
sHeaderValue
The partial header value. (case insensitive)
Returns
True if the header is found and the value case-insensitively contains the parameter
ExistsAndEquals(string, string, bool)
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
sHeaderName
The name of the header to check. (case insensitive)
sHeaderValue
The full header value. (case insensitive)
isUrl
If true, compare the header values as URLs and if false - do a case insensitive string comparison
Returns
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
sHeaderNames
list of headers
Returns
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
headerNames
string[]
FindAll(string)
Returns all instances of the named header
Declaration
public List<HTTPHeaderItem> FindAll(string sHeaderName)
Parameters
sHeaderName
Header name
Returns
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>, uint, bool)
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
pipe
The data pipe (used for HTTP2 settings and decoding header data)
dataStream
Array containing the data (request/response)
streamId
The HTTP/2 stream ID
useNewDecoder
If true, a new HPACK decoder instance will be used (to prevent polluting the default decoder table).
Returns
List<HeaderField>
Array of "key: value" string objects
GetEnumerator()
Enumerator for HTTPHeader storage collection
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
sHeaderName
Name of the header
sTokenName
Name of the token
Returns
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
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
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
arrToRemove
string[]
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
sOldHeaderName
The name of the header to rename. (case insensitive)
sNewHeaderName
The new name for the header.
Returns
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
An array containing HTTPHeaderItems