当前位置: 首页>>代码示例>>Java>>正文


Java BasicHeaderElementIterator类代码示例

本文整理汇总了Java中org.apache.http.message.BasicHeaderElementIterator的典型用法代码示例。如果您正苦于以下问题:Java BasicHeaderElementIterator类的具体用法?Java BasicHeaderElementIterator怎么用?Java BasicHeaderElementIterator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BasicHeaderElementIterator类属于org.apache.http.message包,在下文中一共展示了BasicHeaderElementIterator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getKeepAliveDuration

import org.apache.http.message.BasicHeaderElementIterator; //导入依赖的package包/类
public long getKeepAliveDuration(HttpResponse response, HttpContext context) {
    if (response == null) {
        throw new IllegalArgumentException("HTTP response may not be null");
    }
    HeaderElementIterator it = new BasicHeaderElementIterator(
            response.headerIterator(HTTP.CONN_KEEP_ALIVE));
    while (it.hasNext()) {
        HeaderElement he = it.nextElement();
        String param = he.getName();
        String value = he.getValue();
        if (value != null && param.equalsIgnoreCase("timeout")) {
            try {
                return Long.parseLong(value) * 1000;
            } catch(NumberFormatException ignore) {
            }
        }
    }
    return -1;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:DefaultConnectionKeepAliveStrategy.java

示例2: getKeepAliveDuration

import org.apache.http.message.BasicHeaderElementIterator; //导入依赖的package包/类
@Override
public 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.getName();
    String value = he.getValue();
    if (value != null && param.equalsIgnoreCase("timeout")) {
      long timeout = Long.parseLong(value) * 1000;
      if (timeout > 20 * 1000) {
        return 20 * 1000;
      } else {
        return timeout;
      }
    }
  }
  return 5 * 1000;
}
 
开发者ID:osswangxining,项目名称:iotplatform,代码行数:19,代码来源:WebhookMsgHandler.java

示例3: getKeepAliveDuration

import org.apache.http.message.BasicHeaderElementIterator; //导入依赖的package包/类
@Override
public long getKeepAliveDuration(HttpResponse response, HttpContext context) {
  // Honor 'keep-alive' header
  HeaderElementIterator it = new BasicHeaderElementIterator(
      response.headerIterator(HTTP.CONN_KEEP_ALIVE));
  while (it.hasNext()) {
    HeaderElement he = it.nextElement();
    String param = he.getName();
    String value = he.getValue();
    if (value != null && param.equalsIgnoreCase("timeout")) {
      try {
        return Long.parseLong(value) * 1000;
      } catch (NumberFormatException ignore) {
        // Do nothing
      }
    }
  }
  // otherwise keep alive for 30 seconds
  return 30 * 1000;
}
 
开发者ID:SparkTC,项目名称:stocator,代码行数:21,代码来源:SwiftConnectionManager.java

示例4: getKeepAliveDuration

import org.apache.http.message.BasicHeaderElementIterator; //导入依赖的package包/类
@Override
public long getKeepAliveDuration(final HttpResponse response, final HttpContext context) {
   Args.notNull(response, "HTTP response");
   final HeaderElementIterator it = new BasicHeaderElementIterator(response.headerIterator(HTTP.CONN_KEEP_ALIVE));
   while (it.hasNext()) {
      final HeaderElement he = it.nextElement();
      final String param = he.getName();
      final String value = he.getValue();
      if (value != null && param.equalsIgnoreCase("timeout")) {
         try {
            return Long.parseLong(value) * 1000;
         } catch (final NumberFormatException ignore) {
            LOGGER.warn("keep alive timeout could not be parsed: param=" + param + " value:" + value, ignore);
         }
      }
   }
   return DEFAULT_KEEP_ALIVE;
}
 
开发者ID:Qyotta,项目名称:axon-eventstore,代码行数:19,代码来源:DefaultConnectionKeepAliveStrategy.java

示例5: getKeepAliveDuration

import org.apache.http.message.BasicHeaderElementIterator; //导入依赖的package包/类
public long getKeepAliveDuration(final HttpResponse response, final HttpContext context) {
    Args.notNull(response, "HTTP response");
    final HeaderElementIterator it = new BasicHeaderElementIterator(
            response.headerIterator(HTTP.CONN_KEEP_ALIVE));
    while (it.hasNext()) {
        final HeaderElement he = it.nextElement();
        final String param = he.getName();
        final String value = he.getValue();
        if (value != null && param.equalsIgnoreCase("timeout")) {
            try {
                return Long.parseLong(value) * 1000;
            } catch(final NumberFormatException ignore) {
            }
        }
    }
    return -1;
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:18,代码来源:DefaultConnectionKeepAliveStrategyHC4.java

示例6: getKeepAliveDuration

import org.apache.http.message.BasicHeaderElementIterator; //导入依赖的package包/类
public long getKeepAliveDuration(HttpResponse response, HttpContext context) {
    if (response == null) {
        throw new IllegalArgumentException("HTTP response may not be null");
    }
    HeaderElementIterator it = new BasicHeaderElementIterator(response.headerIterator(HTTP.CONN_KEEP_ALIVE));
    while (it.hasNext()) {
        HeaderElement he = it.nextElement();
        String param = he.getName();
        String value = he.getValue();
        if (value != null && param.equalsIgnoreCase("timeout")) {
            try {
                return Long.parseLong(value) * 1000;
            } catch (NumberFormatException ignore) {
            }
        }
    }
    return DEFAULT_KEEP_ALIVE_DURATION;
}
 
开发者ID:crawler-commons,项目名称:http-fetcher,代码行数:19,代码来源:SimpleHttpFetcher.java

示例7: getKeepAliveDuration

import org.apache.http.message.BasicHeaderElementIterator; //导入依赖的package包/类
@Override
public long getKeepAliveDuration(HttpResponse httpResponse, HttpContext httpContext) {

	HeaderElementIterator headerElementIterator = new BasicHeaderElementIterator(httpResponse.headerIterator(HTTP.CONN_KEEP_ALIVE));

	while (headerElementIterator.hasNext()) {

		HeaderElement headerElement = headerElementIterator.nextElement();

		String name = headerElement.getName();
		String value = headerElement.getValue();

		if (value != null && name.equalsIgnoreCase("timeout")) {
			return Long.parseLong(value) * 1000;
		}
	}

	// Set own keep alive duration if server does not have it
	return applicationConfiguration.getRptConnectionPoolCustomKeepAliveTimeout() * 1000;
}
 
开发者ID:AgarwalNeha1,项目名称:gluu,代码行数:21,代码来源:UmaProtectionService.java

示例8: getKeepAliveDuration

import org.apache.http.message.BasicHeaderElementIterator; //导入依赖的package包/类
@Override
public long getKeepAliveDuration(final HttpResponse response, final HttpContext context) {
    Args.notNull(response, "HTTP response");
    final HeaderElementIterator it = new BasicHeaderElementIterator(
            response.headerIterator(HTTP.CONN_KEEP_ALIVE));
    while (it.hasNext()) {
        final HeaderElement he = it.nextElement();
        final String param = he.getName();
        final String value = he.getValue();
        if (value != null && param.equalsIgnoreCase("timeout")) {
            try {
                return Long.parseLong(value) * 1000;
            } catch(final NumberFormatException ignore) {
            }
        }
    }
    return -1;
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:19,代码来源:DefaultConnectionKeepAliveStrategy.java

示例9: getKeepAliveDuration

import org.apache.http.message.BasicHeaderElementIterator; //导入依赖的package包/类
@Override
public 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.getName();
		String value = he.getValue();
		if (value != null && param.equalsIgnoreCase("timeout")) {
			try {
				return Long.parseLong(value) * 1000;
			} catch (NumberFormatException ignore) {
			}
		}
	}
	return keepAliveTime * 1000;
}
 
开发者ID:Kong,项目名称:galileo-agent-java,代码行数:17,代码来源:AnalyticsConnKeepAliveStrategy.java

示例10: getStrategy

import org.apache.http.message.BasicHeaderElementIterator; //导入依赖的package包/类
private ConnectionKeepAliveStrategy getStrategy() {
    return new ConnectionKeepAliveStrategy() {
        @Override
        public 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.getName();
                String value = he.getValue();
                if (value != null && param.equalsIgnoreCase
                        ("timeout")) {
                    return Long.parseLong(value) * 1000;
                }
            }
            return 5 * 1000;
        }
    };
}
 
开发者ID:Bandwidth,项目名称:java-bandwidth,代码行数:20,代码来源:BandwidthClient.java

示例11: getKeepAliveDuration

import org.apache.http.message.BasicHeaderElementIterator; //导入依赖的package包/类
@Override
public long getKeepAliveDuration(HttpResponse httpResponse, HttpContext httpContext) {

	HeaderElementIterator headerElementIterator = new BasicHeaderElementIterator(httpResponse.headerIterator(HTTP.CONN_KEEP_ALIVE));

	while (headerElementIterator.hasNext()) {

		HeaderElement headerElement = headerElementIterator.nextElement();

		String name = headerElement.getName();
		String value = headerElement.getValue();

		if (value != null && name.equalsIgnoreCase("timeout")) {
			return Long.parseLong(value) * 1000;
		}
	}

	// Set own keep alive duration if server does not have it
	return appConfiguration.getRptConnectionPoolCustomKeepAliveTimeout() * 1000;
}
 
开发者ID:GluuFederation,项目名称:oxTrust,代码行数:21,代码来源:UmaPermissionService.java

示例12: getKeepAliveStrategy

import org.apache.http.message.BasicHeaderElementIterator; //导入依赖的package包/类
/**
 * @return The connection keep alive strategy.
 */
private ConnectionKeepAliveStrategy getKeepAliveStrategy() {

    return (response, context) -> {
        // Honor 'keep-alive' header
        HeaderElementIterator it = new BasicHeaderElementIterator(response.headerIterator(HTTP.CONN_KEEP_ALIVE));
        while (it.hasNext()) {
            HeaderElement he = it.nextElement();
            String param = he.getName();
            String value = he.getValue();
            if (value != null && "timeout".equalsIgnoreCase(param)) {
                try {
                    return Long.parseLong(value) * 1000;
                } catch(NumberFormatException ignore) {
                    // let's move on the next header value
                    break;
                }
            }
        }
        // otherwise use the default value
        return defaultKeepAlive * 1000;
    };
}
 
开发者ID:Talend,项目名称:data-prep,代码行数:26,代码来源:HttpClient.java

示例13: getKeepAliveDuration

import org.apache.http.message.BasicHeaderElementIterator; //导入依赖的package包/类
public long getKeepAliveDuration(HttpResponse response, HttpContext context) {
    if (response == null) {
        throw new IllegalArgumentException("HTTP response may not be null");
    }
    HeaderElementIterator it = new BasicHeaderElementIterator(
            response.headerIterator(HTTP.CONN_KEEP_ALIVE));
    while (it.hasNext()) {
        HeaderElement he = it.nextElement();
        String param = he.getName(); 
        String value = he.getValue();
        if (value != null && param.equalsIgnoreCase("timeout")) {
            try {
                return Long.parseLong(value) * 1000;
            } catch(NumberFormatException ignore) {
            }
        }
    }
    return -1;
}
 
开发者ID:tdopires,项目名称:cJUnit-mc626,代码行数:20,代码来源:DefaultConnectionKeepAliveStrategy.java

示例14: authenticate

import org.apache.http.message.BasicHeaderElementIterator; //导入依赖的package包/类
public void authenticate(String username, String password) throws 
        IOException {  
    
    HttpResponse response = Request.Post("https://app.mybasis.com/login")
        .bodyForm(Form.form().add("username",  username).add("password",  password).build())
        .execute().returnResponse();        
    
    /* find the access token */ 
    HeaderElementIterator it = new BasicHeaderElementIterator(response.headerIterator("Set-Cookie"));                
    while (it.hasNext()) {
        HeaderElement elem = it.nextElement(); 
        if (elem.getName().equals("access_token")) { 
            accessToken = elem.getValue(); 
            return; 
        }
    }
    
    /* we didn't find an access token, we couldnt login. */ 
    throw new IOException("Unable to login");
}
 
开发者ID:hof,项目名称:basis-java-api,代码行数:21,代码来源:BasisDownload.java

示例15: getKeepAliveDuration

import org.apache.http.message.BasicHeaderElementIterator; //导入依赖的package包/类
@Override
public 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.getName();
        String value = he.getValue();
        if (value != null && param.equalsIgnoreCase("timeout")) {
            try {
                return Long.parseLong(value) * 1000;
            } catch (NumberFormatException ignore) {
            }
        }
    }
    return keepAliveTimeOut * 1000;
}
 
开发者ID:knightliao,项目名称:disconf,代码行数:18,代码来源:HttpClientKeepAliveStrategy.java


注:本文中的org.apache.http.message.BasicHeaderElementIterator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。