当前位置: 首页>>代码示例>>C#>>正文


C# HttpRequestHeaders.Add方法代码示例

本文整理汇总了C#中System.Net.Http.Headers.HttpRequestHeaders.Add方法的典型用法代码示例。如果您正苦于以下问题:C# HttpRequestHeaders.Add方法的具体用法?C# HttpRequestHeaders.Add怎么用?C# HttpRequestHeaders.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Net.Http.Headers.HttpRequestHeaders的用法示例。


在下文中一共展示了HttpRequestHeaders.Add方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CopyRequestHeaders

        public static void CopyRequestHeaders(IEnumerable<KeyValuePair<string, IEnumerable<string>>> source,
            HttpRequestHeaders destination)
        {
            foreach (var header in source)
            {
                switch (header.Key)
                {
                    case "User-Agent":
                        destination.Add(header.Key, "dev/1.0");
                        break;

                    case "Via":
                        break;

                    default:
                        destination.Add(header.Key, String.Join(",", header.Value));
                        break;
                }
            }
        }
开发者ID:yanghongjie,项目名称:DotNetDev,代码行数:20,代码来源:HttpUtils.cs

示例2: Populate

 internal void Populate(HttpRequestHeaders headers)
 {
     if (this.CacheControl != null)
     {
         headers.Add("response-cache-control", this.CacheControl);
     }
     if (this.ContentDisposition != null)
     {
         headers.Add("response-content-disposition", this.ContentDisposition);
     }
     if (this.ContentEncoding != null)
     {
         headers.Add("response-content-encoding", this.ContentEncoding);
     }
     if (this.ContentLanguage != null)
     {
         headers.Add("response-content-language", this.ContentLanguage);
     }
     if (this.ContentType != null)
     {
         headers.Add("response-content-type", this.ContentType);
     }
     if (this.Expires != null)
     {
         headers.Add("response-expires", this.Expires);
     }
 }
开发者ID:zhongleiyang,项目名称:win8SDK,代码行数:27,代码来源:ResponseHeaderOverrides.cs

示例3: SetHeaders

 // I would have prefered to return a list of headers instead of relying on a side effect,
 // but I was having problems getting the accept header to work properly. If anyone has any
 // refactoring ideas, I'm listening...
 public void SetHeaders(HttpRequestHeaders headers)
 {
     headers.Add(Constants.AuthorizationHeaderName, this.AuthorizationHeader());
     headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
 }
开发者ID:dalealleshouse,项目名称:AzureTextAnalytics,代码行数:8,代码来源:RequestHeaderFactory.cs

示例4: SetHeaders

        /// <summary>
        ///     Resets the headers to make any request to the Nexon Api look legit
        /// </summary>
        /// <param name="headers">The <see cref="HttpRequestHeaderCollection" /> that gets modified</param>
        private static void SetHeaders(HttpRequestHeaders headers)
        {
            headers.Clear();

            headers.Accept.ParseAdd("application/json, text/javascript, */*; q=0.01");
            headers.AcceptEncoding.ParseAdd("gzip,deflate");
            headers.AcceptLanguage.ParseAdd("en-GB,en-us;q=0.8,en;q=0.6");
            headers.UserAgent.ParseAdd(GetUserAgent);
            headers.Connection.TryParseAdd("keep-alive");
            headers.Host = new Uri(LoginUrl).Host;
            headers.Add("X-Requested-With", "XMLHttpRequest");
        }
开发者ID:Razzstep,项目名称:LaunchPlusPlus,代码行数:16,代码来源:WebApi.cs

示例5: AddAuthenticationHeaders

 /// <summary>
 /// Adds the user name and password as http headers elements for the corresponding bulk file upload operation.
 /// </summary>
 /// <param name="requestHeaders">The headers collection to which authentication requests should be added.</param>
 protected internal override void AddAuthenticationHeaders(HttpRequestHeaders requestHeaders)
 {
     requestHeaders.Add("UserName", _username);
     requestHeaders.Add("Password", _password);
 }
开发者ID:BingAds,项目名称:BingAds-dotNet-SDK,代码行数:9,代码来源:PasswordAuthentication.cs

示例6: UpdateHeaders

 private void UpdateHeaders( HttpRequestHeaders headers ) {
     headers.Add( "PddToken", PddToken );
     headers.Authorization = AuthenticationHeaderValue.Parse( $"OAuth {AuthToken.Token}" );
 }
开发者ID:kasthack,项目名称:kasthack.yandex.pdd,代码行数:4,代码来源:PddRawApi.cs

示例7: AddAuthenticationHeaders

        /// <summary>
        /// Adds the AuthenticationToken header element for the corresponding bulk file upload operation. 
        /// </summary>
        /// <param name="requestHeaders">The headers collection to which authentication requests should be added.</param>
        protected internal override void AddAuthenticationHeaders(HttpRequestHeaders requestHeaders)
        {
            if (OAuthTokens == null)
            {
                throw new InvalidOperationException(ErrorMessages.GetFullOAuthAccessTokenNotRequestedMessage(GetType()));
            }

            requestHeaders.Add("AuthenticationToken", OAuthTokens.AccessToken);
        }
开发者ID:BingAds,项目名称:BingAds-dotNet-SDK,代码行数:13,代码来源:OAuthAuthorization.cs

示例8: TransferHeaders

        private Task TransferHeaders(IHeaderDictionary sourceHeaders, HttpRequestHeaders destinationHeaders)
        {
            destinationHeaders.Add("Accept", sourceHeaders.ContainsKey("Accept")
                ? sourceHeaders["Accept"].ToString()
                : "image/*");

            destinationHeaders.Add("Accept-Encoding", sourceHeaders.ContainsKey("Accept-Encoding")
                ? sourceHeaders["Accept-Encoding"].ToString()
                : string.Empty);

            destinationHeaders.Add("X-Frame-Options", _defaultHeaders["X-Frame-Options"]);

            destinationHeaders.Add("X-XSS-Protection", _defaultHeaders["X-XSS-Protection"]);

            destinationHeaders.Add("X-Content-Type-Options", _defaultHeaders["X-Content-Type-Options"]);

            //destinationHeaders.Add("Content-Security-Policy", _defaultHeaders["Content-Security-Policy"]);

            return Task.FromResult(0);
        }
开发者ID:maartenba,项目名称:CamoDotNet,代码行数:20,代码来源:CamoServer.cs


注:本文中的System.Net.Http.Headers.HttpRequestHeaders.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。