本文整理匯總了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);
}
示例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;
}
示例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));
}
示例4: AddRequestHeaders
private void AddRequestHeaders(HttpRequestMessage request)
{
foreach (string requestHeaderKey in requestHeaders.Keys)
{
request.AddHeader(requestHeaderKey, requestHeaders[requestHeaderKey].ToString
());
}
}