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