1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
|
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
#pragma warning disable 1634, 1691
namespace System.ServiceModel.Web
{
using System.Globalization;
using System.Net;
using System.Runtime;
using System.ServiceModel;
using System.ServiceModel.Channels;
public class OutgoingWebRequestContext
{
OperationContext operationContext;
internal OutgoingWebRequestContext(OperationContext operationContext)
{
Fx.Assert(operationContext != null, "operationContext is null");
this.operationContext = operationContext;
}
public string Accept
{
get { return this.MessageProperty.Headers[HttpRequestHeader.Accept]; }
set { this.MessageProperty.Headers[HttpRequestHeader.Accept] = value; }
}
public long ContentLength
{
get { return long.Parse(this.MessageProperty.Headers[HttpRequestHeader.ContentLength], CultureInfo.InvariantCulture); }
set { this.MessageProperty.Headers[HttpRequestHeader.ContentLength] = value.ToString(CultureInfo.InvariantCulture); }
}
public string ContentType
{
get { return this.MessageProperty.Headers[HttpRequestHeader.ContentType]; }
set { this.MessageProperty.Headers[HttpRequestHeader.ContentType] = value; }
}
public WebHeaderCollection Headers
{
get { return this.MessageProperty.Headers; }
}
public string IfMatch
{
get { return this.MessageProperty.Headers[HttpRequestHeader.IfMatch]; }
set { this.MessageProperty.Headers[HttpRequestHeader.IfMatch] = value; }
}
public string IfModifiedSince
{
get { return this.MessageProperty.Headers[HttpRequestHeader.IfModifiedSince]; }
set { this.MessageProperty.Headers[HttpRequestHeader.IfModifiedSince] = value; }
}
public string IfNoneMatch
{
get { return this.MessageProperty.Headers[HttpRequestHeader.IfNoneMatch]; }
set { this.MessageProperty.Headers[HttpRequestHeader.IfNoneMatch] = value; }
}
public string IfUnmodifiedSince
{
get { return this.MessageProperty.Headers[HttpRequestHeader.IfUnmodifiedSince]; }
set { this.MessageProperty.Headers[HttpRequestHeader.IfUnmodifiedSince] = value; }
}
public string Method
{
get { return this.MessageProperty.Method; }
set { this.MessageProperty.Method = value; }
}
public bool SuppressEntityBody
{
get { return this.MessageProperty.SuppressEntityBody; }
set { this.MessageProperty.SuppressEntityBody = value; }
}
public string UserAgent
{
get { return this.MessageProperty.Headers[HttpRequestHeader.UserAgent]; }
set { this.MessageProperty.Headers[HttpRequestHeader.UserAgent] = value; }
}
HttpRequestMessageProperty MessageProperty
{
get
{
if (!operationContext.OutgoingMessageProperties.ContainsKey(HttpRequestMessageProperty.Name))
{
operationContext.OutgoingMessageProperties.Add(HttpRequestMessageProperty.Name, new HttpRequestMessageProperty());
}
return operationContext.OutgoingMessageProperties[HttpRequestMessageProperty.Name] as HttpRequestMessageProperty;
}
}
}
}
|