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


Java HeaderElement.getValue方法代码示例

本文整理汇总了Java中org.apache.http.HeaderElement.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java HeaderElement.getValue方法的具体用法?Java HeaderElement.getValue怎么用?Java HeaderElement.getValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.http.HeaderElement的用法示例。


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

示例1: getKeepAliveDuration

import org.apache.http.HeaderElement; //导入方法依赖的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: estimateHeaderElementLen

import org.apache.http.HeaderElement; //导入方法依赖的package包/类
/**
 * Estimates the length of a formatted header element.
 *
 * @param elem      the header element to format, or <code>null</code>
 *
 * @return  a length estimate, in number of characters
 */
protected int estimateHeaderElementLen(final HeaderElement elem) {
    if (elem == null)
        return 0;

    int result = elem.getName().length(); // name
    final String value = elem.getValue();
    if (value != null) {
        // assume quotes, but no escaped characters
        result += 3 + value.length(); // ="value"
    }

    final int parcnt = elem.getParameterCount();
    if (parcnt > 0) {
        for (int i=0; i<parcnt; i++) {
            result += 2 +                   // ; <param>
                estimateNameValuePairLen(elem.getParameter(i));
        }
    }

    return result;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:29,代码来源:BasicHeaderValueFormatter.java

示例3: parseElements

import org.apache.http.HeaderElement; //导入方法依赖的package包/类
public HeaderElement[] parseElements(final CharArrayBuffer buffer,
                                     final ParserCursor cursor) {

    if (buffer == null) {
        throw new IllegalArgumentException("Char array buffer may not be null");
    }
    if (cursor == null) {
        throw new IllegalArgumentException("Parser cursor may not be null");
    }

    List<HeaderElement> elements = new ArrayList<HeaderElement>();
    while (!cursor.atEnd()) {
        HeaderElement element = parseHeaderElement(buffer, cursor);
        if (!(element.getName().length() == 0 && element.getValue() == null)) {
            elements.add(element);
        }
    }
    return elements.toArray(new HeaderElement[elements.size()]);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:BasicHeaderValueParser.java

示例4: getKeepAliveDuration

import org.apache.http.HeaderElement; //导入方法依赖的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

示例5: getKeepAliveDuration

import org.apache.http.HeaderElement; //导入方法依赖的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

示例6: getKeepAliveDuration

import org.apache.http.HeaderElement; //导入方法依赖的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

示例7: estimateHeaderElementLen

import org.apache.http.HeaderElement; //导入方法依赖的package包/类
/**
 * Estimates the length of a formatted header element.
 *
 * @param elem      the header element to format, or <code>null</code>
 *
 * @return  a length estimate, in number of characters
 */
protected int estimateHeaderElementLen(final HeaderElement elem) {
    if (elem == null) {
        return 0;
    }

    int result = elem.getName().length(); // name
    final String value = elem.getValue();
    if (value != null) {
        // assume quotes, but no escaped characters
        result += 3 + value.length(); // ="value"
    }

    final int parcnt = elem.getParameterCount();
    if (parcnt > 0) {
        for (int i=0; i<parcnt; i++) {
            result += 2 +                   // ; <param>
                estimateNameValuePairLen(elem.getParameter(i));
        }
    }

    return result;
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:30,代码来源:BasicHeaderValueFormatterHC4.java

示例8: getKeepAliveDuration

import org.apache.http.HeaderElement; //导入方法依赖的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

示例9: getKeepAliveDuration

import org.apache.http.HeaderElement; //导入方法依赖的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

示例10: getKeepAliveDuration

import org.apache.http.HeaderElement; //导入方法依赖的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

示例11: getKeepAliveDuration

import org.apache.http.HeaderElement; //导入方法依赖的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

示例12: getKeepAliveDuration

import org.apache.http.HeaderElement; //导入方法依赖的package包/类
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 30 * 1000; //默认30秒
}
 
开发者ID:penggle,项目名称:xproject,代码行数:16,代码来源:HttpClientUtils.java

示例13: parse

import org.apache.http.HeaderElement; //导入方法依赖的package包/类
protected List<Cookie> parse(final HeaderElement[] elems, final CookieOrigin origin)
            throws MalformedCookieException {
    List<Cookie> cookies = new ArrayList<Cookie>(elems.length);
    for (HeaderElement headerelement : elems) {
        String name = headerelement.getName();
        String value = headerelement.getValue();
        if (name == null || name.length() == 0) {
            throw new MalformedCookieException("Cookie name may not be empty");
        }

        BasicClientCookie cookie = new BasicClientCookie(name, value);
        cookie.setPath(getDefaultPath(origin));
        cookie.setDomain(getDefaultDomain(origin));

        // cycle through the parameters
        NameValuePair[] attribs = headerelement.getParameters();
        for (int j = attribs.length - 1; j >= 0; j--) {
            NameValuePair attrib = attribs[j];
            String s = attrib.getName().toLowerCase(Locale.ENGLISH);

            cookie.setAttribute(s, attrib.getValue());

            CookieAttributeHandler handler = findAttribHandler(s);
            if (handler != null) {
                handler.parse(cookie, attrib.getValue());
            }
        }
        cookies.add(cookie);
    }
    return cookies;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:32,代码来源:CookieSpecBase.java

示例14: parseNextElement

import org.apache.http.HeaderElement; //导入方法依赖的package包/类
private void parseNextElement() {
    // loop while there are headers left to parse
    while (this.headerIt.hasNext() || this.cursor != null) {
        if (this.cursor == null || this.cursor.atEnd()) {
            // get next header value
            bufferHeaderValue();
        }
        // Anything buffered?
        if (this.cursor != null) {
            // loop while there is data in the buffer
            while (!this.cursor.atEnd()) {
                HeaderElement e = this.parser.parseHeaderElement(this.buffer, this.cursor);
                if (!(e.getName().length() == 0 && e.getValue() == null)) {
                    // Found something
                    this.currentElement = e;
                    return;
                }
            }
            // if at the end of the buffer
            if (this.cursor.atEnd()) {
                // discard it
                this.cursor = null;
                this.buffer = null;
            }
        }
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:28,代码来源:BasicHeaderElementIterator.java

示例15: parseElements

import org.apache.http.HeaderElement; //导入方法依赖的package包/类
public HeaderElement[] parseElements(final CharArrayBuffer buffer,
                                     final ParserCursor cursor) {
    Args.notNull(buffer, "Char array buffer");
    Args.notNull(cursor, "Parser cursor");
    final List<HeaderElement> elements = new ArrayList<HeaderElement>();
    while (!cursor.atEnd()) {
        final HeaderElement element = parseHeaderElement(buffer, cursor);
        if (!(element.getName().length() == 0 && element.getValue() == null)) {
            elements.add(element);
        }
    }
    return elements.toArray(new HeaderElement[elements.size()]);
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:14,代码来源:BasicHeaderValueParserHC4.java


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