Statistics
| Branch: | Revision:

root / trunk / Pithos.Network / TimeoutRetryCondition.cs @ 3c43ec9b

History | View | Annotate | Download (986 Bytes)

1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Net;
5
using System.Text;
6
using Hammock.Retries;
7

    
8
namespace Pithos.Network
9
{
10
    class TimeoutRetryCondition:RetryResultCondition
11
    {
12
        public override Predicate<Hammock.Web.WebQueryResult> RetryIf
13
        {
14
            get
15
            {
16
                return r =>
17
                           {
18
                               var responseStatus = r.ResponseHttpStatusCode;
19
                               if (r.Exception == null)
20
                                   return false;
21
                               if (!(r.Exception is WebException))
22
                                   return false;
23
                               var exceptionStatus = ((WebException) r.Exception).Status;
24
                               return (r.Exception != null
25
                                       && (exceptionStatus == WebExceptionStatus.Timeout));
26
                           };
27
            }
28
        }
29
    }
30
}