public virtual long GetKeepAliveDuration(HttpResponse response, HttpContext context
                                                 )
        {
            Args.NotNull(response, "HTTP response");
            HeaderElementIterator it = new BasicHeaderElementIterator(response.HeaderIterator
                                                                          (HTTP.ConnKeepAlive));

            while (it.HasNext())
            {
                HeaderElement he    = it.NextElement();
                string        param = he.GetName();
                string        value = he.GetValue();
                if (value != null && Sharpen.Runtime.EqualsIgnoreCase(param, "timeout"))
                {
                    try
                    {
                        return(long.Parse(value) * 1000);
                    }
                    catch (FormatException)
                    {
                    }
                }
            }
            return(-1);
        }
Пример #2
0
		public override long getKeepAliveDuration(HttpResponse response, HttpContext context)
		{
			HeaderElementIterator it = new BasicHeaderElementIterator(response.headerIterator(HTTP.CONN_KEEP_ALIVE));
			while (it.hasNext())
			{
				HeaderElement he = it.nextElement();
				string param = he.Name;
				string value = he.Value;
				if (!string.ReferenceEquals(value, null) && param.Equals("timeout", StringComparison.CurrentCultureIgnoreCase))
				{
					try
					{
						return long.Parse(value) * 1000;
					}
					catch (System.FormatException)
					{
					}
				}
			}
			return keepAliveTimeOut * 1000;
		}