Skip to content

Commit

Permalink
Corrected Timeout code
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Murphy committed Feb 12, 2016
1 parent 60d25ca commit 3484c44
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion LoveSeat/Support/CouchBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public abstract class CouchBase
protected readonly AuthenticationType authType;
protected string baseUri;
private TtlDictionary<string, Cookie> cookiestore = new TtlDictionary<string, Cookie>();
private int? timeout;
protected int? timeout;

protected CouchBase()
{
Expand Down
16 changes: 11 additions & 5 deletions LoveSeat/Support/CouchRequest.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.IO;
using System.Net;
using System.Text;
Expand Down Expand Up @@ -41,7 +42,6 @@ public CouchRequest(string uri, Cookie authCookie, string eTag)
request.KeepAlive = true;
if (authCookie != null)
request.Headers.Add("Cookie", "AuthSession=" + authCookie.Value);
request.Timeout = 10000;
}

/// <summary>
Expand Down Expand Up @@ -74,7 +74,6 @@ public CouchRequest(string uri, string username, string password)
request.Headers.Add("Accept-Language", "en-us");
request.ContentType = "application/json";
request.KeepAlive = true;
request.Timeout = 10000;
}


Expand Down Expand Up @@ -152,9 +151,16 @@ public CouchRequest Json()
return this;
}

public CouchRequest Timeout(int timeoutMs)
public CouchRequest Timeout(int? timeoutMs)
{
request.Timeout = timeoutMs;
if (timeoutMs.HasValue)
{
request.Timeout = timeoutMs.Value;
}
else
{
request.Timeout = (int)TimeSpan.FromHours(1).TotalMilliseconds;
}
return this;
}

Expand Down Expand Up @@ -193,7 +199,7 @@ public CouchResponse GetCouchResponse()
{
if (failedAuth == true)
{
throw;
throw webEx;
}
var response = (HttpWebResponse)webEx.Response;
if (response == null)
Expand Down

0 comments on commit 3484c44

Please sign in to comment.