// Properties
 public string this[HttpRequestHeader reqHeader]
 {
     get
     {
         return HeaderStrings[(int)reqHeader];
     }
 }
        public void BuildWebRequest_RestrictedTypes_AddsCorrectHeader(HttpRequestHeader header, string value)
        {
            request.AddHeader(header, value);

            var webrequest = HttpWebRequestBuilder.BuildFrom(request);

            Assert.That(webrequest.Headers[header], Is.Not.Null);
        }
Пример #3
0
 private static string ToString(HttpRequestHeader value)
 {
     switch (value)
     {
         case HttpRequestHeader.CacheControl:
             return "Cache-Control";
         case HttpRequestHeader.KeepAlive:
             return "Keep-Alive";
         case HttpRequestHeader.TransferEncoding:
             return "Transfer-Encoding";
         case HttpRequestHeader.ContentLength:
             return "Content-Length";
         case HttpRequestHeader.ContentType:
             return "Content-Type";
         case HttpRequestHeader.ContentEncoding:
             return "Content-Encoding";
         case HttpRequestHeader.ContentLanguage:
             return "Content-Language";
         case HttpRequestHeader.ContentLocation:
             return "Content-Location";
         case HttpRequestHeader.ContentMd5:
             return "Content-MD5";
         case HttpRequestHeader.ContentRange:
             return "Content-Range";
         case HttpRequestHeader.LastModified:
             return "Last-Modified";
         case HttpRequestHeader.AcceptCharset:
             return "Accept-Charset";
         case HttpRequestHeader.AcceptEncoding:
             return "Accept-Encoding";
         case HttpRequestHeader.AcceptLanguage:
             return "Accept-Language";
         case HttpRequestHeader.IfMatch:
             return "If-Match";
         case HttpRequestHeader.IfModifiedSince:
             return "If-Modified-Since";
         case HttpRequestHeader.IfNoneMatch:
             return "If-None-Match";
         case HttpRequestHeader.IfRange:
             return "If-Range";
         case HttpRequestHeader.IfUnmodifiedSince:
             return "If-Unmodified-Since";
         case HttpRequestHeader.MaxForwards:
             return "Max-Forwards";
         case HttpRequestHeader.ProxyAuthorization:
             return "Proxy-Authorization";
         case HttpRequestHeader.UserAgent:
             return "User-Agent";
         default:
             return value.ToString();
     }
 }
Пример #4
0
 public string this[HttpRequestHeader header]
 {
     get
     {
         if (!AllowHttpRequestHeader)
         {
             throw new InvalidOperationException(SR.net_headers_req);
         }
         return this[header.GetName()];
     }
     set
     {
         if (!AllowHttpRequestHeader)
         {
             throw new InvalidOperationException(SR.net_headers_req);
         }
         this[header.GetName()] = value;
     }
 }
Пример #5
0
		bool IsValidHeader (HttpRequestHeader header)
		{
			switch (header) {
			case HttpRequestHeader.Connection:
			case HttpRequestHeader.Date:
			case HttpRequestHeader.KeepAlive:
			case HttpRequestHeader.Trailer:
			case HttpRequestHeader.TransferEncoding:
			case HttpRequestHeader.Upgrade:
			case HttpRequestHeader.Via:
			case HttpRequestHeader.Warning:
			case HttpRequestHeader.Allow:
			case HttpRequestHeader.ContentLength:
			case HttpRequestHeader.ContentType:
			case HttpRequestHeader.ContentLocation:
			case HttpRequestHeader.ContentRange:
			case HttpRequestHeader.LastModified:
			case HttpRequestHeader.Accept:
			case HttpRequestHeader.AcceptCharset:
			case HttpRequestHeader.AcceptEncoding:
			case HttpRequestHeader.AcceptLanguage:
			// Authorization was not valid before SL4
			// case HttpRequestHeader.Authorization:
			case HttpRequestHeader.Cookie:
			case HttpRequestHeader.Expect:
			case HttpRequestHeader.Host:
			case HttpRequestHeader.IfModifiedSince:
			case HttpRequestHeader.MaxForwards:
			// ProxyAuthorization was not valid before SL4
			// case HttpRequestHeader.ProxyAuthorization:
			case HttpRequestHeader.Referer:
			case HttpRequestHeader.Te:
			// Range was not valid in SL2 but is accepted in SL3
			// case HttpRequestHeader.Range:
			case HttpRequestHeader.UserAgent:
				return false;
			default:
				return true;
			}
		}
Пример #6
0
		public string this[HttpRequestHeader hrh]
		{
			get {
				return Get (RequestHeaderToString (hrh));
			}
			
			set {
				Add (RequestHeaderToString (hrh), value);
			}
		}
Пример #7
0
		string RequestHeaderToString (HttpRequestHeader value)
		{
			switch (value){
			case HttpRequestHeader.CacheControl:
				return "cache-control";
			case HttpRequestHeader.Connection:
				return "connection";
			case HttpRequestHeader.Date:
				return "date";
			case HttpRequestHeader.KeepAlive:
				return "keep-alive";
			case HttpRequestHeader.Pragma:
				return "pragma";
			case HttpRequestHeader.Trailer:
				return "trailer";
			case HttpRequestHeader.TransferEncoding:
				return "transfer-encoding";
			case HttpRequestHeader.Upgrade:
				return "upgrade";
			case HttpRequestHeader.Via:
				return "via";
			case HttpRequestHeader.Warning:
				return "warning";
			case HttpRequestHeader.Allow:
				return "allow";
			case HttpRequestHeader.ContentLength:
				return "content-length";
			case HttpRequestHeader.ContentType:
				return "content-type";
			case HttpRequestHeader.ContentEncoding:
				return "content-encoding";
			case HttpRequestHeader.ContentLanguage:
				return "content-language";
			case HttpRequestHeader.ContentLocation:
				return "content-location";
			case HttpRequestHeader.ContentMd5:
				return "content-md5";
			case HttpRequestHeader.ContentRange:
				return "content-range";
			case HttpRequestHeader.Expires:
				return "expires";
			case HttpRequestHeader.LastModified:
				return "last-modified";
			case HttpRequestHeader.Accept:
				return "accept";
			case HttpRequestHeader.AcceptCharset:
				return "accept-charset";
			case HttpRequestHeader.AcceptEncoding:
				return "accept-encoding";
			case HttpRequestHeader.AcceptLanguage:
				return "accept-language";
			case HttpRequestHeader.Authorization:
				return "authorization";
			case HttpRequestHeader.Cookie:
				return "cookie";
			case HttpRequestHeader.Expect:
				return "expect";
			case HttpRequestHeader.From:
				return "from";
			case HttpRequestHeader.Host:
				return "host";
			case HttpRequestHeader.IfMatch:
				return "if-match";
			case HttpRequestHeader.IfModifiedSince:
				return "if-modified-since";
			case HttpRequestHeader.IfNoneMatch:
				return "if-none-match";
			case HttpRequestHeader.IfRange:
				return "if-range";
			case HttpRequestHeader.IfUnmodifiedSince:
				return "if-unmodified-since";
			case HttpRequestHeader.MaxForwards:
				return "max-forwards";
			case HttpRequestHeader.ProxyAuthorization:
				return "proxy-authorization";
			case HttpRequestHeader.Referer:
				return "referer";
			case HttpRequestHeader.Range:
				return "range";
			case HttpRequestHeader.Te:
				return "te";
			case HttpRequestHeader.Translate:
				return "translate";
			case HttpRequestHeader.UserAgent:
				return "user-agent";
			default:
				throw new InvalidOperationException ();
			}
		}
Пример #8
0
 public void AddHeader(HttpRequestHeader headerType, string value)
 {
     _headers.Add(headerType, value);
 }
Пример #9
0
 private void SetHeaderValue(HttpRequestHeader name, string value)
 {
     if (value != null)
     {
         _headers[name] = value;
     }
     else
     {
         _headers.Remove(name);
     }
 }
Пример #10
0
 private string GetKnownHeader(HttpRequestHeader header)
 {
     return Interop.HttpApi.GetKnownHeader(RequestBuffer, OriginalBlobAddress, (int)header);
 }
Пример #11
0
 public HeaderValueAttribute(HttpRequestHeader header)
 {
     _headerName = HttpRequestHeaders.HeaderNameFor(header);
 }
 public static void Add(this WebHeaderCollection col, HttpRequestHeader key, string value)
 {
     col[key] = value;
 }
 public void Add(HttpRequestHeader header, string value) { }
 public void Remove(HttpRequestHeader header) { }
Пример #15
0
		public string this [HttpRequestHeader header] {
			get { return this [HttpRequestHeaderToString (header)]; }
			set {
				string h = HttpRequestHeaderToString (header);
				if (validate)
					ValidateHeader (h);
				headers [h] = value;
			}
		}
Пример #16
0
 internal static string Convert(HttpRequestHeader header)
 {
     return Convert (header.ToString ());
 }
Пример #17
0
 internal static void Add(this WebHeaderCollection collection, HttpRequestHeader header, string value)
 {
     collection[header] = value;
 }
Пример #18
0
 /// <summary>
 /// Removes the specified header from the collection.
 /// </summary>
 /// <param name="header">
 /// A <see cref="HttpRequestHeader"/> to remove from the collection.
 /// </param>
 /// <exception cref="InvalidOperationException">
 /// The current <see cref="WebHeaderCollection"/> instance does not allow any of <see cref="HttpRequestHeader"/> values.
 /// </exception>
 /// <exception cref="ArgumentException">
 /// <paramref name="header"/> is a restricted header.
 /// </exception>
 public void Remove(HttpRequestHeader header)
 {
     DoWithCheckingState (RemoveWithoutCheckingName, Convert (header), null, false, false);
 }
Пример #19
0
 /// <summary>
 /// Sets the specified header to the specified value.
 /// </summary>
 /// <param name="header">
 /// A <see cref="HttpRequestHeader"/> to set.
 /// </param>
 /// <param name="value">
 /// A <see cref="string"/> that contains the value of the header to set.
 /// </param>
 /// <exception cref="InvalidOperationException">
 /// The current <see cref="WebHeaderCollection"/> instance does not allow any of <see cref="HttpRequestHeader"/> values.
 /// </exception>
 /// <exception cref="ArgumentException">
 ///   <para>
 ///   <paramref name="header"/> is a restricted header.
 ///   </para>
 ///   <para>
 ///   -or-
 ///   </para>
 ///   <para>
 ///   <paramref name="value"/> contains invalid characters.
 ///   </para>
 /// </exception>
 /// <exception cref="ArgumentOutOfRangeException">
 /// The length of <paramref name="value"/> is greater than 65535.
 /// </exception>
 public void Set(HttpRequestHeader header, string value)
 {
     DoWithCheckingState (SetWithoutCheckingName, Convert (header), value, false, true);
 }
Пример #20
0
 // Public methods.
 /// <summary>
 /// Returns the name of the specified request header.
 /// </summary>
 /// <param name="header">The HTTP request header.</param>
 /// <returns>The header name.</returns>
 public static string GetRequestHeaderName(HttpRequestHeader header)
 {
     return HttpUtils.requestHeaderNames[header] as string;
 }
Пример #21
0
        /// <summary>
        /// Gets or sets the specified request <paramref name="header"/> in the collection.
        /// </summary>
        /// <value>
        /// A <see cref="string"/> that contains the value of the specified request <paramref name="header"/>.
        /// </value>
        /// <param name="header">
        /// A <see cref="HttpRequestHeader"/> that indicates a request header.
        /// </param>
        /// <exception cref="InvalidOperationException">
        /// The current <see cref="WebHeaderCollection"/> instance does not allow any of <see cref="HttpRequestHeader"/> values.
        /// </exception>
        /// <exception cref="ArgumentException">
        ///   <para>
        ///   <paramref name="header"/> is a restricted header.
        ///   </para>
        ///   <para>
        ///   -or-
        ///   </para>
        ///   <para>
        ///   <paramref name="value"/> contains invalid characters.
        ///   </para>
        /// </exception>
        /// <exception cref="ArgumentOutOfRangeException">
        /// The length of <paramref name="value"/> is greater than 65535.
        /// </exception>
        public string this[HttpRequestHeader header]
        {
            get {
                return Get (Convert (header));
            }

            set {
                Add (header, value);
            }
        }
Пример #22
0
		public string this [HttpRequestHeader header] {
			get {
				return Get (RequestHeaderToString (header));
			}
			
			set {
				Set (header, value);
			}
		}
Пример #23
0
		// Private Methods

		string RequestHeaderToString (HttpRequestHeader value)
		{
			CheckHeaderConsistency (HeaderInfo.Request);

			switch (value) {
			case HttpRequestHeader.CacheControl:
				return "Cache-Control";
			case HttpRequestHeader.Connection:
				return "Connection";
			case HttpRequestHeader.Date:
				return "Date";
			case HttpRequestHeader.KeepAlive:
				return "Keep-Alive";
			case HttpRequestHeader.Pragma:
				return "Pragma";
			case HttpRequestHeader.Trailer:
				return "Trailer";
			case HttpRequestHeader.TransferEncoding:
				return "Transfer-Encoding";
			case HttpRequestHeader.Upgrade:
				return "Upgrade";
			case HttpRequestHeader.Via:
				return "Via";
			case HttpRequestHeader.Warning:
				return "Warning";
			case HttpRequestHeader.Allow:
				return "Allow";
			case HttpRequestHeader.ContentLength:
				return "Content-Length";
			case HttpRequestHeader.ContentType:
				return "Content-Type";
			case HttpRequestHeader.ContentEncoding:
				return "Content-Encoding";
			case HttpRequestHeader.ContentLanguage:
				return "Content-Language";
			case HttpRequestHeader.ContentLocation:
				return "Content-Location";
			case HttpRequestHeader.ContentMd5:
				return "Content-MD5";
			case HttpRequestHeader.ContentRange:
				return "Content-Range";
			case HttpRequestHeader.Expires:
				return "Expires";
			case HttpRequestHeader.LastModified:
				return "Last-Modified";
			case HttpRequestHeader.Accept:
				return "Accept";
			case HttpRequestHeader.AcceptCharset:
				return "Accept-Charset";
			case HttpRequestHeader.AcceptEncoding:
				return "Accept-Encoding";
			case HttpRequestHeader.AcceptLanguage:
				return "accept-language";
			case HttpRequestHeader.Authorization:
				return "Authorization";
			case HttpRequestHeader.Cookie:
				return "Cookie";
			case HttpRequestHeader.Expect:
				return "Expect";
			case HttpRequestHeader.From:
				return "From";
			case HttpRequestHeader.Host:
				return "Host";
			case HttpRequestHeader.IfMatch:
				return "If-Match";
			case HttpRequestHeader.IfModifiedSince:
				return "If-Modified-Since";
			case HttpRequestHeader.IfNoneMatch:
				return "If-None-Match";
			case HttpRequestHeader.IfRange:
				return "If-Range";
			case HttpRequestHeader.IfUnmodifiedSince:
				return "If-Unmodified-Since";
			case HttpRequestHeader.MaxForwards:
				return "Max-Forwards";
			case HttpRequestHeader.ProxyAuthorization:
				return "Proxy-Authorization";
			case HttpRequestHeader.Referer:
				return "Referer";
			case HttpRequestHeader.Range:
				return "Range";
			case HttpRequestHeader.Te:
				return "TE";
			case HttpRequestHeader.Translate:
				return "Translate";
			case HttpRequestHeader.UserAgent:
				return "User-Agent";
			default:
				throw new InvalidOperationException ();
			}
		}
Пример #24
0
		public void Remove (HttpRequestHeader header)
		{
			Remove (RequestHeaderToString (header));
		}
Пример #25
0
		public void Set (HttpRequestHeader header, string value)
		{
			Set (RequestHeaderToString (header), value);
		}
Пример #26
0
		public void Add (HttpRequestHeader header, string value)
		{
			Add (RequestHeaderToString (header), value);
		}
 public String this[HttpRequestHeader header]
 {
     get { return this[header.ToString()]; }
 }
Пример #28
0
 public void Remove(HttpRequestHeader header) {
     if (!AllowHttpRequestHeader) {
         throw new InvalidOperationException(SR.GetString(SR.net_headers_req));
     }
     this.Remove(UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST_HEADER_ID.ToString((int)header));
 }
Пример #29
0
 public string this[HttpRequestHeader header] {
     get {
         if (!AllowHttpRequestHeader) {
             throw new InvalidOperationException(SR.GetString(SR.net_headers_req));
         }
         return this[UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST_HEADER_ID.ToString((int)header)];
     }
     set {
         if (!AllowHttpRequestHeader) {
             throw new InvalidOperationException(SR.GetString(SR.net_headers_req));
         }
         this[UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST_HEADER_ID.ToString((int)header)] = value;
     }
 }
Пример #30
-1
 public override string this[HttpRequestHeader header]
 {
     get
     {
         return this[HttpHeaderToName.RequestHeaderNames[header]];
     }
     set
     {
         this[HttpHeaderToName.RequestHeaderNames[header]] = value;
     }
 }