當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。