Set() public method

Sets the specified request header to the specified value.
/// /// is a restricted header. /// /// /// -or- /// /// /// contains invalid characters. /// /// /// The length of is greater than 65,535 characters. /// /// The current instance doesn't allow /// the request . ///
public Set ( HttpRequestHeader header, string value ) : void
header HttpRequestHeader /// One of the enum values, represents /// the request header to set. ///
value string /// A that represents the value of the request header to set. ///
return void
        /// <summary>
        /// Adds the specified HTTP header <paramref name="name"/> and <paramref name="value"/> to
        /// the headers for this response.
        /// </summary>
        /// <param name="name">
        /// A <see cref="string"/> that contains the name of the HTTP header to add.
        /// </param>
        /// <param name="value">
        /// A <see cref="string"/> that contains the value of the HTTP header to add.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="name"/> is <see langword="null"/> or <see cref="String.Empty"/>.
        /// </exception>
        /// <exception cref="ArgumentOutOfRangeException">
        /// The length of <paramref name="value"/> is greater than 65,535 characters.
        /// </exception>
        public void AddHeader(string name, string value)
        {
            if (name.IsNullOrEmpty())
            {
                throw new ArgumentNullException("name");
            }

            // TODO: Check for forbidden headers and invalid characters.

            if (value.Length > 65535)
            {
                throw new ArgumentOutOfRangeException("value");
            }

            headers.Set(name, value);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds the specified HTTP header <paramref name="name"/> and
        /// <paramref name="value"/> to the headers for this response.
        /// </summary>
        /// <param name="name">
        /// A <see cref="string"/> that contains the name of the HTTP header to add.
        /// </param>
        /// <param name="value">
        /// A <see cref="string"/> that contains the value of the HTTP header to add.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="name"/> is <see langword="null"/> or empty.
        /// </exception>
        /// <exception cref="ArgumentOutOfRangeException">
        /// The length of <paramref name="value"/> is greater than 65,535 characters.
        /// </exception>
        public void AddHeader(string name, string value)
        {
            if (name == null || name.Length == 0)
            {
                throw new ArgumentNullException("name");
            }

            // TODO: Check for forbidden headers and invalid characters.
            if (value.Length > 65535)
            {
                throw new ArgumentOutOfRangeException(
                          "value", "Greater than 65,535 characters.");
            }

            _headers.Set(name, value);
        }
Ejemplo n.º 3
0
        public void AddHeader(string name, string value)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }

            if (name == "")
            {
                throw new ArgumentException("'name' cannot be empty", "name");
            }

            // TODO: check for forbidden headers and invalid characters
            if (value.Length > 65535)
            {
                throw new ArgumentOutOfRangeException("value");
            }

            headers.Set(name, value);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Adds an HTTP header with the specified <paramref name="name"/> and
 /// <paramref name="value"/> to the headers for the response.
 /// </summary>
 /// <param name="name">
 /// A <see cref="string"/> that represents the name of the header to add.
 /// </param>
 /// <param name="value">
 /// A <see cref="string"/> that represents the value of the header to add.
 /// </param>
 /// <exception cref="ArgumentException">
 ///   <para>
 ///   <paramref name="name"/> or <paramref name="value"/> contains invalid characters.
 ///   </para>
 ///   <para>
 ///   -or-
 ///   </para>
 ///   <para>
 ///   <paramref name="name"/> is a restricted header name.
 ///   </para>
 /// </exception>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="name"/> is <see langword="null"/> or empty.
 /// </exception>
 /// <exception cref="ArgumentOutOfRangeException">
 /// The length of <paramref name="value"/> is greater than 65,535 characters.
 /// </exception>
 /// <exception cref="InvalidOperationException">
 ///   <para>
 ///   The response has already been sent.
 ///   </para>
 ///   <para>
 ///   -or-
 ///   </para>
 ///   <para>
 ///   The header cannot be allowed to add to the current headers.
 ///   </para>
 /// </exception>
 /// <exception cref="ObjectDisposedException">
 /// This object is closed.
 /// </exception>
 public void AddHeader(string name, string value)
 {
     checkDisposedOrHeadersSent();
     _headers.Set(name, value);
 }