Class HTTPHeaders
Base class for RequestHeaders and ResponseHeaders
Inheritance
Inherited Members
Namespace: Fiddler
Assembly: FiddlerCore.dll
Syntax
public abstract class HTTPHeaders
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. |
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)
Declaration
public abstract bool AssignFromString(string sHeaders)
Parameters
System.String
sHeaders
|
Returns
System.Boolean
|
ByteCount()
Get byte count of this HTTP header instance. NOTE: This method should've been abstract.
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 |
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)
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)
Parameters
System.String
sHeaderName
The name of the header to check. (case insensitive) |
System.String
sHeaderValue
The full header value. (case insensitive) |
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. |
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()
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()
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. |
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 |