java.net.URLConnection.getHeaderFieldInt()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(6.4k)|赞(0)|评价(0)|浏览(191)

本文整理了Java中java.net.URLConnection.getHeaderFieldInt()方法的一些代码示例,展示了URLConnection.getHeaderFieldInt()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。URLConnection.getHeaderFieldInt()方法的具体详情如下:
包路径:java.net.URLConnection
类名称:URLConnection
方法名:getHeaderFieldInt

URLConnection.getHeaderFieldInt介绍

[英]Returns the specified header value as a number. Returns the defaultValue if no such header field could be found or the value could not be parsed as an Integer.
[中]以数字形式返回指定的标题值。如果找不到此类标头字段或无法将值解析为整数,则返回defaultValue。

代码示例

代码示例来源:origin: robovm/robovm

/**
 * Returns the content length in bytes specified by the response header field
 * {@code content-length} or {@code -1} if this field is not set.
 *
 * @return the value of the response header field {@code content-length}.
 */
public int getContentLength() {
  return getHeaderFieldInt("Content-Length", -1);
}

代码示例来源:origin: org.eclipse.jetty.osgi/jetty-osgi-boot-warurl

@Override
public int getHeaderFieldInt(String name, int Default)
{
  return _conn.getHeaderFieldInt(name,Default);
}

代码示例来源:origin: MobiVM/robovm

/**
 * Returns the content length in bytes specified by the response header field
 * {@code content-length} or {@code -1} if this field is not set.
 *
 * @return the value of the response header field {@code content-length}.
 */
public int getContentLength() {
  return getHeaderFieldInt("Content-Length", -1);
}

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

/**
 * Returns the content length in bytes specified by the response header field
 * {@code content-length} or {@code -1} if this field is not set.
 *
 * @return the value of the response header field {@code content-length}.
 */
public int getContentLength() {
  return getHeaderFieldInt("Content-Length", -1);
}

代码示例来源:origin: ibinti/bugvm

/**
 * Returns the content length in bytes specified by the response header field
 * {@code content-length} or {@code -1} if this field is not set.
 *
 * @return the value of the response header field {@code content-length}.
 */
public int getContentLength() {
  return getHeaderFieldInt("Content-Length", -1);
}

代码示例来源:origin: com.jtransc/jtransc-rt

/**
 * Returns the content length in bytes specified by the response header field
 * {@code content-length} or {@code -1} if this field is not set.
 *
 * @return the value of the response header field {@code content-length}.
 */
public int getContentLength() {
  return getHeaderFieldInt("Content-Length", -1);
}

代码示例来源:origin: FlexoVM/flexovm

/**
 * Returns the content length in bytes specified by the response header field
 * {@code content-length} or {@code -1} if this field is not set.
 *
 * @return the value of the response header field {@code content-length}.
 */
public int getContentLength() {
  return getHeaderFieldInt("Content-Length", -1);
}

代码示例来源:origin: com.bugvm/bugvm-rt

/**
 * Returns the content length in bytes specified by the response header field
 * {@code content-length} or {@code -1} if this field is not set.
 *
 * @return the value of the response header field {@code content-length}.
 */
public int getContentLength() {
  return getHeaderFieldInt("Content-Length", -1);
}

代码示例来源:origin: com.gluonhq/robovm-rt

/**
 * Returns the content length in bytes specified by the response header field
 * {@code content-length} or {@code -1} if this field is not set.
 *
 * @return the value of the response header field {@code content-length}.
 */
public int getContentLength() {
  return getHeaderFieldInt("Content-Length", -1);
}

代码示例来源:origin: org.jboss/jboss-common-core

public int getHeaderFieldInt(String name, int _default) {
 return delegateConnection.getHeaderFieldInt(name, _default);
}

代码示例来源:origin: freeplane/freeplane

public int getHeaderFieldInt(String name, int Default) {
  return connection.getHeaderFieldInt(name, Default);
}

代码示例来源:origin: stackoverflow.com

private long getContentLength(HttpURLConnection conn) {
 String transferEncoding = conn.getHeaderField("Transfer-Encoding");
 if (transferEncoding == null || transferEncoding.equalsIgnoreCase("chunked")) {
   return conn.getHeaderFieldInt("Content-Length", -1);
 } else {
   return -1;
 }

代码示例来源:origin: org.microemu/microemu-javase

public int getHeaderFieldInt(String name, int def) throws IOException {
  if (cn == null) {
    throw new IOException();
  }
  if (!connected) {
    cn.connect();
    connected = true;
  }
  return cn.getHeaderFieldInt(name, def);
}

代码示例来源:origin: org.samba.jcifs/jcifs

public int getHeaderFieldInt(String header, int def) {
  try {
    handshake();
  } catch (IOException ex) { }
  return connection.getHeaderFieldInt(header, def);
}

代码示例来源:origin: MER-C/wiki-java

/**
 *  Checks for database lag and sleeps if {@code lag < getMaxLag()}.
 *  @param connection the URL connection used in the request
 *  @return true if there was sufficient database lag.
 *  @see #getMaxLag()
 *  @see <a href="https://mediawiki.org/wiki/Manual:Maxlag_parameter">
 *  MediaWiki documentation</a>
 *  @since 0.32
 */
protected synchronized boolean checkLag(URLConnection connection)
{
  int lag = connection.getHeaderFieldInt("X-Database-Lag", -5);
  // X-Database-Lag is the current lag rounded down to the nearest integer.
  // Thus, we need to retry in case of equality.
  if (lag >= maxlag)
  {
    try
    {
      int time = connection.getHeaderFieldInt("Retry-After", 10);
      logger.log(Level.WARNING, "Current database lag {0} s exceeds maxlag of {1} s, waiting {2} s.", new Object[] { lag, maxlag, time });
      Thread.sleep(time * 1000L);
    }
    catch (InterruptedException ignored)
    {
    }
    return true;
  }
  return false;
}

代码示例来源:origin: com.github.houbie/rhino-mod

urlConnection.getDate());
final long corrected_received_age = Math.max(apparent_age,
    urlConnection.getHeaderFieldInt("Age", 0) * 1000L);
final long response_delay = response_time - request_time;
final long corrected_initial_age = corrected_received_age +

代码示例来源:origin: com.github.tntim96/rhino

urlConnection.getDate());
final long corrected_received_age = Math.max(apparent_age,
    urlConnection.getHeaderFieldInt("Age", 0) * 1000L);
final long response_delay = response_time - request_time;
final long corrected_initial_age = corrected_received_age +

代码示例来源:origin: geogebra/geogebra

urlConnection.getDate());
final long corrected_received_age = Math.max(apparent_age,
    urlConnection.getHeaderFieldInt("Age", 0) * 1000L);
final long response_delay = response_time - request_time;
final long corrected_initial_age = corrected_received_age +

代码示例来源:origin: ro.isdc.wro4j/rhino

urlConnection.getDate());
final long corrected_received_age = Math.max(apparent_age,
    urlConnection.getHeaderFieldInt("Age", 0) * 1000L);
final long response_delay = response_time - request_time;
final long corrected_initial_age = corrected_received_age +

代码示例来源:origin: octo-online/reactive-audit

@Test(expected = NetworkReactiveAuditException.class)
public void getHeaderFieldInt()
    throws IOException
{
  Assume.assumeTrue(IOTestTools.isNetworkConnected());
  ReactiveAudit.off.commit();
  URLConnection conn = new URL("http://" + HOST + ":" + PORT).openConnection();
  TestTools.strict.commit();
  conn.getHeaderFieldInt("expiration", 0);
}

相关文章

URLConnection类方法