protected override void AddProperties(Message message) { HostedRequestContainer requestContainer = new HostedRequestContainer(this.hostedHttpContext.result); HttpRequestMessageProperty requestProperty = new HttpRequestMessageProperty(requestContainer); requestProperty.Method = this.hostedHttpContext.HttpMethod; // Uri.Query always includes the '?' if (this.hostedHttpContext.result.RequestUri.Query.Length > 1) { requestProperty.QueryString = this.hostedHttpContext.result.RequestUri.Query.Substring(1); } message.Properties.Add(HttpRequestMessageProperty.Name, requestProperty); message.Properties.Add(HostingMessageProperty.Name, CreateMessagePropertyFromHostedResult(this.hostedHttpContext.result)); message.Properties.Via = this.hostedHttpContext.result.RequestUri; RemoteEndpointMessageProperty remoteEndpointProperty = new RemoteEndpointMessageProperty(requestContainer); message.Properties.Add(RemoteEndpointMessageProperty.Name, remoteEndpointProperty); this.hostedHttpContext.SetRequestContainer(requestContainer); }
private void CloseHostedRequestContainer() { if (this.requestContainer != null) { this.requestContainer.Close(); this.requestContainer = null; } }
// Accessing the headers of an already replied HttpRequest instance causes an Access Violation in hosted mode. // In one-way scenarios, reply happens before the user gets the message. That's why we are disabling all access // to HostedRequestContainer (CSDMain 34014). void CloseHostedRequestContainer() { // RequestContext.RequestMessage property can throw rather than create a message. // This means we never created a message and never cached the IIS properties. // At this point the user may return a reply, so requestContainer is allowed to be null. if (this.requestContainer != null) { this.requestContainer.Close(); this.requestContainer = null; } }
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); }
void SetRequestContainer(HostedRequestContainer requestContainer) { this.requestContainer = requestContainer; }
private void SetRequestContainer(HostedRequestContainer requestContainer) { this.requestContainer = requestContainer; }