本文整理汇总了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
());
}
}