My Project
|
Provides a collection of the HTTP headers associated with a request or response. More...
Public Member Functions | |
WebHeaderCollection () | |
Initializes a new instance of the WebHeaderCollection class. | |
void | Add (string header) |
Adds the specified header to the collection. | |
void | Add (HttpRequestHeader header, string value) |
Adds the specified request header with the specified value to the collection. | |
void | Add (HttpResponseHeader header, string value) |
Adds the specified response header with the specified value to the collection. | |
override void | Add (string name, string value) |
Adds a header with the specified name and value to the collection. | |
override void | Clear () |
Removes all headers from the collection. | |
override string | Get (int index) |
Get the value of the header at the specified index in the collection. | |
override string | Get (string name) |
Get the value of the header with the specified name in the collection. | |
override IEnumerator | GetEnumerator () |
Gets the enumerator used to iterate through the collection. | |
override string | GetKey (int index) |
Get the name of the header at the specified index in the collection. | |
override string[] | GetValues (int index) |
Get the values of the header at the specified index in the collection. | |
override string[] | GetValues (string name) |
Get the values of the header with the specified name in the collection. | |
override void | GetObjectData (SerializationInfo serializationInfo, StreamingContext streamingContext) |
Populates a SerializationInfo instance with the data needed to serialize this instance. | |
override void | OnDeserialization (object sender) |
Implements the ISerializable interface and raises the deserialization event when the deserialization is complete. | |
void | Remove (HttpRequestHeader header) |
Removes the specified request header from the collection. | |
void | Remove (HttpResponseHeader header) |
Removes the specified response header from the collection. | |
override void | Remove (string name) |
Removes the specified header from the collection. | |
void | Set (HttpRequestHeader header, string value) |
Sets the specified request header to the specified value. | |
void | Set (HttpResponseHeader header, string value) |
Sets the specified response header to the specified value. | |
override void | Set (string name, string value) |
Sets the specified header to the specified value. | |
byte[] | ToByteArray () |
Converts the current instance to an array of byte. | |
override string | ToString () |
Returns a string that represents the current instance. | |
Static Public Member Functions | |
static bool | IsRestricted (string headerName) |
Determines whether the specified HTTP header can be set for the request. | |
static bool | IsRestricted (string headerName, bool response) |
Determines whether the specified HTTP header can be set for the request or the response. | |
Protected Member Functions | |
WebHeaderCollection (SerializationInfo serializationInfo, StreamingContext streamingContext) | |
Initializes a new instance of the WebHeaderCollection class from the specified instances of the SerializationInfo and StreamingContext classes. | |
void | AddWithoutValidate (string headerName, string headerValue) |
Adds a header to the collection without checking if the header is on the restricted header list. | |
Properties | |
override string[] | AllKeys [get] |
Gets all header names in the collection. | |
override int | Count [get] |
Gets the number of headers in the collection. | |
string | this[HttpRequestHeader header] [get, set] |
Gets or sets the specified request header. | |
string | this[HttpResponseHeader header] [get, set] |
Gets or sets the specified response header. | |
override NameObjectCollectionBase.KeysCollection | Keys [get] |
Gets a collection of header names in the collection. | |
Provides a collection of the HTTP headers associated with a request or response.
|
inlineprotected |
Initializes a new instance of the WebHeaderCollection class from the specified instances of the SerializationInfo and StreamingContext classes.
serializationInfo | A SerializationInfo that contains the serialized object data. |
streamingContext | A StreamingContext that specifies the source for the deserialization. |
ArgumentNullException | serializationInfo is null . |
ArgumentException | An element with the specified name is not found in serializationInfo . |
|
inline |
Adds the specified request header with the specified value to the collection.
header | One of the HttpRequestHeader enum values. It specifies the request header to add. |
value | A string that specifies the value of the header to add. |
ArgumentException | value contains an invalid character. -or- header is a restricted header. |
ArgumentOutOfRangeException | The length of value is greater than 65,535 characters. |
InvalidOperationException | This instance does not allow the request header. |
|
inline |
Adds the specified response header with the specified value to the collection.
header | One of the HttpResponseHeader enum values. It specifies the response header to add. |
value | A string that specifies the value of the header to add. |
ArgumentException | value contains an invalid character. -or- header is a restricted header. |
ArgumentOutOfRangeException | The length of value is greater than 65,535 characters. |
InvalidOperationException | This instance does not allow the response header. |
|
inline |
Adds the specified header to the collection.
header | A string that specifies the header to add, with the name and value separated by a colon character (':'). |
ArgumentNullException | header is null . |
ArgumentException | header is an empty string. -or- header does not contain a colon character. -or- The name part of header is an empty string. -or- The name part of header is a string of spaces. -or- The name part of header contains an invalid character. -or- The value part of header contains an invalid character. -or- header is a restricted header. |
ArgumentOutOfRangeException | The length of the value part of header is greater than 65,535 characters. |
InvalidOperationException | This instance does not allow the header. |
|
inline |
Adds a header with the specified name and value to the collection.
name | A string that specifies the name of the header to add. |
value | A string that specifies the value of the header to add. |
ArgumentNullException | name is null . |
ArgumentException | name is an empty string. -or- name is a string of spaces. -or- name contains an invalid character. -or- value contains an invalid character. -or- name is a restricted header name. |
ArgumentOutOfRangeException | The length of value is greater than 65,535 characters. |
InvalidOperationException | This instance does not allow the header. |
|
inlineprotected |
Adds a header to the collection without checking if the header is on the restricted header list.
headerName | A string that specifies the name of the header to add. |
headerValue | A string that specifies the value of the header to add. |
ArgumentNullException | headerName is null . |
ArgumentException | headerName is an empty string. -or- headerName is a string of spaces. -or- headerName contains an invalid character. -or- headerValue contains an invalid character. |
ArgumentOutOfRangeException | The length of headerValue is greater than 65,535 characters. |
InvalidOperationException | This instance does not allow the header. |
|
inline |
Get the value of the header at the specified index in the collection.
index | An int that specifies the zero-based index of the header to find. |
ArgumentOutOfRangeException | index is out of allowable range of indexes for the collection. |
|
inline |
Get the value of the header with the specified name in the collection.
null
if not found.
name | A string that specifies the name of the header to find. |
|
inline |
Gets the enumerator used to iterate through the collection.
|
inline |
Get the name of the header at the specified index in the collection.
index | An int that specifies the zero-based index of the header to find. |
ArgumentOutOfRangeException | index is out of allowable range of indexes for the collection. |
|
inline |
Populates a SerializationInfo instance with the data needed to serialize this instance.
serializationInfo | A SerializationInfo to populate with the data. |
streamingContext | A StreamingContext that specifies the destination for the serialization. |
ArgumentNullException | serializationInfo is null . |
|
inline |
Get the values of the header at the specified index in the collection.
null
if not present.
index | An int that specifies the zero-based index of the header to find. |
ArgumentOutOfRangeException | index is out of allowable range of indexes for the collection. |
|
inline |
Get the values of the header with the specified name in the collection.
null
if not present.
name | A string that specifies the name of the header to find. |
|
inlinestatic |
Determines whether the specified HTTP header can be set for the request.
true
if the header cannot be set; otherwise, false
. headerName | A string that specifies the name of the header to test. |
ArgumentNullException | headerName is null . |
ArgumentException | headerName is an empty string. -or- headerName is a string of spaces. -or- headerName contains an invalid character. |
|
inlinestatic |
Determines whether the specified HTTP header can be set for the request or the response.
true
if the header cannot be set; otherwise, false
. headerName | A string that specifies the name of the header to test. |
response | A bool: true if the test is for the response; otherwise, false . |
ArgumentNullException | headerName is null . |
ArgumentException | headerName is an empty string. -or- headerName is a string of spaces. -or- headerName contains an invalid character. |
|
inline |
Implements the ISerializable interface and raises the deserialization event when the deserialization is complete.
sender | An object instance that represents the source of the deserialization event. |
|
inline |
Removes the specified request header from the collection.
header | One of the HttpRequestHeader enum values. It specifies the request header to remove. |
ArgumentException | header is a restricted header. |
InvalidOperationException | This instance does not allow the request header. |
|
inline |
Removes the specified response header from the collection.
header | One of the HttpResponseHeader enum values. It specifies the response header to remove. |
ArgumentException | header is a restricted header. |
InvalidOperationException | This instance does not allow the response header. |
|
inline |
Removes the specified header from the collection.
name | A string that specifies the name of the header to remove. |
ArgumentNullException | name is null . |
ArgumentException | name is an empty string. -or- name is a string of spaces. -or- name contains an invalid character. -or- name is a restricted header name. |
InvalidOperationException | This instance does not allow the header. |
|
inline |
Sets the specified request header to the specified value.
header | One of the HttpRequestHeader enum values. It specifies the request header to set. |
value | A string that specifies the value of the request header to set. |
ArgumentException | value contains an invalid character. -or- header is a restricted header. |
ArgumentOutOfRangeException | The length of value is greater than 65,535 characters. |
InvalidOperationException | This instance does not allow the request header. |
|
inline |
Sets the specified response header to the specified value.
header | One of the HttpResponseHeader enum values. It specifies the response header to set. |
value | A string that specifies the value of the response header to set. |
ArgumentException | value contains an invalid character. -or- header is a restricted header. |
ArgumentOutOfRangeException | The length of value is greater than 65,535 characters. |
InvalidOperationException | This instance does not allow the response header. |
|
inline |
Sets the specified header to the specified value.
name | A string that specifies the name of the header to set. |
value | A string that specifies the value of the header to set. |
ArgumentNullException | name is null . |
ArgumentException | name is an empty string. -or- name is a string of spaces. -or- name contains an invalid character. -or- value contains an invalid character. -or- name is a restricted header name. |
ArgumentOutOfRangeException | The length of value is greater than 65,535 characters. |
InvalidOperationException | This instance does not allow the header. |
|
inline |
Converts the current instance to an array of byte.
|
inline |
Returns a string that represents the current instance.
|
get |
Gets all header names in the collection.
An array of string that contains all header names in the collection.
|
get |
Gets the number of headers in the collection.
An int that represents the number of headers in the collection.
|
get |
Gets a collection of header names in the collection.
A NameObjectCollectionBase.KeysCollection that contains all header names in the collection.
|
getset |
Gets or sets the specified request header.
A string that represents the value of the request header.
header | One of the HttpRequestHeader enum values. It specifies the request header to get or set. |
ArgumentException | header is a restricted header. -or- value contains an invalid character. |
ArgumentOutOfRangeException | The length of value is greater than 65,535 characters. |
InvalidOperationException | This instance does not allow the request header. |
|
getset |
Gets or sets the specified response header.
A string that represents the value of the response header.
header | One of the HttpResponseHeader enum values. It specifies the response header to get or set. |
ArgumentException | header is a restricted header. -or- value contains an invalid character. |
ArgumentOutOfRangeException | The length of value is greater than 65,535 characters. |
InvalidOperationException | This instance does not allow the response header. |