Skip to content

Commit

Permalink
added the readwritetimeout property to the context
Browse files Browse the repository at this point in the history
  • Loading branch information
ElizabethOkerio committed Jun 8, 2020
1 parent 2e7a49e commit 5bd4892
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
30 changes: 30 additions & 0 deletions src/Microsoft.OData.Client/DataServiceContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ public class DataServiceContext
#if !PORTABLELIB // Timeout not available
/// <summary>time-out value in seconds, 0 for default</summary>
private int timeout;

/// <summary>read or write time-out value in seconds, 0 for default</summary>
private int readWriteTimeout;
#endif
/// <summary>whether to use post-tunneling for PUT/DELETE</summary>
private bool postTunneling;
Expand Down Expand Up @@ -507,6 +510,33 @@ public virtual int Timeout
this.timeout = value;
}
}

/// <summary>Gets or sets the readwrite time-out option (in seconds) that is used for the underlying HTTP request to the data service.</summary>
/// <returns>An integer that indicates the time interval (in seconds) before readwritetime-out of a service request.</returns>
/// <remarks>
/// 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.
/// </remarks>
public virtual int ReadWriteTimeout
{
get
{
return this.readWriteTimeout;
}

set
{
if (value < 0)
{
throw Error.ArgumentOutOfRange("ReadWriteTimeout");
}

this.readWriteTimeout = value;
}
}
#endif

/// <summary>Gets or sets a Boolean value that indicates whether to use post tunneling.</summary>
Expand Down
8 changes: 6 additions & 2 deletions src/Microsoft.OData.Client/ODataRequestMessageWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 9 additions & 0 deletions src/Microsoft.OData.Client/RequestInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,15 @@ internal int Timeout
{
get { return this.Context.Timeout; }
}

/// <summary>
/// Get the read or write timeout span in seconds to use for the underlying HTTP request to the data service.
/// </summary>
internal int ReadWriteTimeout
{
get { return this.Context.ReadWriteTimeout; }
}

#endif

/// <summary>
Expand Down

0 comments on commit 5bd4892

Please sign in to comment.