當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。