From 72c48fafb1c67378f6828f186eb3df1b4a9cef2c Mon Sep 17 00:00:00 2001 From: Elizabeth Okerio Date: Thu, 4 Jun 2020 23:43:12 -0700 Subject: [PATCH] added the readwritetimeout property to the context --- .../DataServiceContext.cs | 30 +++++++++++++++++++ .../ODataRequestMessageWrapper.cs | 8 +++-- src/Microsoft.OData.Client/RequestInfo.cs | 9 ++++++ 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.OData.Client/DataServiceContext.cs b/src/Microsoft.OData.Client/DataServiceContext.cs index a926f2c39e..69853a8aa5 100644 --- a/src/Microsoft.OData.Client/DataServiceContext.cs +++ b/src/Microsoft.OData.Client/DataServiceContext.cs @@ -115,6 +115,9 @@ public class DataServiceContext #if !PORTABLELIB // Timeout not available /// time-out value in seconds, 0 for default private int timeout; + + /// read or write time-out value in seconds, 0 for default + private int readWriteTimeout; #endif /// whether to use post-tunneling for PUT/DELETE private bool postTunneling; @@ -507,6 +510,33 @@ public virtual int Timeout this.timeout = value; } } + + /// Gets or sets the readwrite time-out option (in seconds) that is used for the underlying HTTP request to the data service. + /// An integer that indicates the time interval (in seconds) before readwritetime-out of a service request. + /// + /// A value of 0 will use the default readwritetimeout of the underlying HTTP request. + /// This value must be set before executing any query or update operations against + /// the target data service for it to have effect on the on the request. + /// The value may be changed between requests to a data service and the new value + /// will be picked up by the next data service request. + /// + public virtual int ReadWriteTimeout + { + get + { + return this.readWriteTimeout; + } + + set + { + if (value < 0) + { + throw Error.ArgumentOutOfRange("ReadWriteTimeout"); + } + + this.readWriteTimeout = value; + } + } #endif /// Gets or sets a Boolean value that indicates whether to use post tunneling. diff --git a/src/Microsoft.OData.Client/ODataRequestMessageWrapper.cs b/src/Microsoft.OData.Client/ODataRequestMessageWrapper.cs index b10b4d9097..f00ace27d2 100644 --- a/src/Microsoft.OData.Client/ODataRequestMessageWrapper.cs +++ b/src/Microsoft.OData.Client/ODataRequestMessageWrapper.cs @@ -161,8 +161,12 @@ internal static ODataRequestMessageWrapper CreateRequestMessageWrapper(BuildingR if (requestInfo.Timeout != 0) { requestMessage.Timeout = requestInfo.Timeout; - //set readwritetimeout value as the set timeout value - requestMessage.ReadWriteTimeout = requestInfo.Timeout; + + } + + if (requestInfo.ReadWriteTimeout != 0) + { + requestMessage.ReadWriteTimeout = requestInfo.ReadWriteTimeout; } #endif diff --git a/src/Microsoft.OData.Client/RequestInfo.cs b/src/Microsoft.OData.Client/RequestInfo.cs index bb87a6b6af..ed74ebd877 100644 --- a/src/Microsoft.OData.Client/RequestInfo.cs +++ b/src/Microsoft.OData.Client/RequestInfo.cs @@ -156,6 +156,15 @@ internal int Timeout { get { return this.Context.Timeout; } } + + /// + /// Get the read or write timeout span in seconds to use for the underlying HTTP request to the data service. + /// + internal int ReadWriteTimeout + { + get { return this.Context.ReadWriteTimeout; } + } + #endif ///