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

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

本文整理了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

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

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

  1. @Override
  2. public int getHeaderFieldInt(String name, int Default)
  3. {
  4. return _conn.getHeaderFieldInt(name,Default);
  5. }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  1. public int getHeaderFieldInt(String name, int def) throws IOException {
  2. if (cn == null) {
  3. throw new IOException();
  4. }
  5. if (!connected) {
  6. cn.connect();
  7. connected = true;
  8. }
  9. return cn.getHeaderFieldInt(name, def);
  10. }

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

  1. public int getHeaderFieldInt(String header, int def) {
  2. try {
  3. handshake();
  4. } catch (IOException ex) { }
  5. return connection.getHeaderFieldInt(header, def);
  6. }

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

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

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

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

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

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

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

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

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

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

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

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

相关文章

URLConnection类方法