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


C# HttpRequestMessage.AddHeader方法代码示例

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


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

示例1: ConfigureHttpRequestMessage

            public override void ConfigureHttpRequestMessage(HttpRequestMessage message)
            {
                message.Method = new HttpMethod(this.hostedHttpContext.result.GetHttpMethod());
                message.RequestUri = this.hostedHttpContext.result.RequestUri;
                foreach (string webHeaderKey in this.hostedHttpContext.result.Application.Context.Request.Headers.Keys)
                {
                    message.AddHeader(webHeaderKey, this.hostedHttpContext.result.Application.Context.Request.Headers[webHeaderKey]);
                }

                HostedRequestContainer requestContainer = new HostedRequestContainer(this.hostedHttpContext.result);
                RemoteEndpointMessageProperty remoteEndpointProperty = new RemoteEndpointMessageProperty(requestContainer);
                message.Properties.Add(RemoteEndpointMessageProperty.Name, remoteEndpointProperty);
            }
开发者ID:uQr,项目名称:referencesource,代码行数:13,代码来源:HostedHttpContext.cs

示例2: CreateRequestMessage

        private static HttpRequestMessage CreateRequestMessage(Message message, HttpRequestMessageProperty requestMessageProperty)
        {
            Fx.Assert(message != null, "The 'message' parameter should not be null.");
            Fx.Assert(requestMessageProperty != null, "The 'requestMessageProperty' parameter should not be null.");
            
            HttpRequestMessage request = new HttpRequestMessage();
            request.RequestUri = message.Properties.Via;

            Fx.Assert(requestMessageProperty.Method != null, "The HttpRequestMessageProperty class ensures the 'Method' property will never be null.");
            request.Method = new HttpMethod(requestMessageProperty.Method);

            request.Content = CreateMessageContent(message, requestMessageProperty.SuppressEntityBody);

            WebHeaderCollection headers = requestMessageProperty.Headers;
            foreach (string headerKey in headers.AllKeys)
            {
                request.AddHeader(headerKey, headers[headerKey]);
            }

            request.CopyPropertiesFromMessage(message);

            return request;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:23,代码来源:MessageExtensionMethods.cs

示例3: ConfigureHttpRequestMessage

 public override void ConfigureHttpRequestMessage(HttpRequestMessage message)
 {
     message.Method = new HttpMethod(this.listenerHttpContext.listenerContext.Request.HttpMethod);
     message.RequestUri = this.listenerHttpContext.listenerContext.Request.Url;
     foreach (string webHeaderKey in this.listenerHttpContext.listenerContext.Request.Headers.Keys)
     {
         message.AddHeader(webHeaderKey, this.listenerHttpContext.listenerContext.Request.Headers[webHeaderKey]);
     }
     message.Properties.Add(RemoteEndpointMessageProperty.Name, new RemoteEndpointMessageProperty(this.listenerHttpContext.listenerContext.Request.RemoteEndPoint));
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:10,代码来源:HttpRequestContext.cs

示例4: AddRequestHeaders

 private void AddRequestHeaders(HttpRequestMessage request)
 {
     foreach (string requestHeaderKey in requestHeaders.Keys)
     {
         request.AddHeader(requestHeaderKey, requestHeaders[requestHeaderKey].ToString
             ());
     }
 }
开发者ID:jonlipsky,项目名称:couchbase-lite-net,代码行数:8,代码来源:ChangeTracker.cs


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