com.gargoylesoftware.htmlunit.WebClient.getPrintContentOnFailingStatusCode()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(3.1k)|赞(0)|评价(0)|浏览(102)

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

WebClient.getPrintContentOnFailingStatusCode介绍

[英]Returns true if the content of the resulting document will be printed to the console in the event of a failing response code.
[中]如果在响应代码失败的情况下,结果文档的内容将打印到控制台,则返回true。

代码示例

代码示例来源:origin: org.jenkins-ci/htmlunit

/**
 * <span style="color:red">INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.</span>
 *
 * <p>Logs the response's content if its status code indicates a request failure and
 * {@link #getPrintContentOnFailingStatusCode()} returns <tt>true</tt>.
 *
 * @param webResponse the response whose content may be logged
 */
public void printContentIfNecessary(final WebResponse webResponse) {
  final String contentType = webResponse.getContentType();
  final int statusCode = webResponse.getStatusCode();
  final boolean successful = (statusCode >= HttpStatus.SC_OK && statusCode < HttpStatus.SC_MULTIPLE_CHOICES);
  if (getPrintContentOnFailingStatusCode() && !successful) {
    LOG.info("statusCode=[" + statusCode + "] contentType=[" + contentType + "]");
    LOG.info(webResponse.getContentAsString());
  }
}

代码示例来源:origin: org.jvnet.hudson/htmlunit

/**
 * <span style="color:red">INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.</span>
 *
 * <p>Logs the response's content if its status code indicates a request failure and
 * {@link #getPrintContentOnFailingStatusCode()} returns <tt>true</tt>.
 *
 * @param webResponse the response whose content may be logged
 */
public void printContentIfNecessary(final WebResponse webResponse) {
  final String contentType = webResponse.getContentType();
  final int statusCode = webResponse.getStatusCode();
  final boolean successful = (statusCode >= HttpStatus.SC_OK && statusCode < HttpStatus.SC_MULTIPLE_CHOICES);
  if (getPrintContentOnFailingStatusCode() && !successful) {
    LOG.info("statusCode=[" + statusCode + "] contentType=[" + contentType + "]");
    LOG.info(webResponse.getContentAsString());
  }
}

代码示例来源:origin: net.disy.htmlunit/htmlunit

/**
 * <span style="color:red">INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.</span>
 *
 * <p>Logs the response's content if its status code indicates a request failure and
 * {@link #getPrintContentOnFailingStatusCode()} returns <tt>true</tt>.
 *
 * @param webResponse the response whose content may be logged
 */
public void printContentIfNecessary(final WebResponse webResponse) {
  final String contentType = webResponse.getContentType();
  final int statusCode = webResponse.getStatusCode();
  final boolean successful = (statusCode >= HttpStatus.SC_OK && statusCode < HttpStatus.SC_MULTIPLE_CHOICES);
  if (getPrintContentOnFailingStatusCode() && !successful) {
    LOG.info("statusCode=[" + statusCode + "] contentType=[" + contentType + "]");
    LOG.info(webResponse.getContentAsString());
  }
}

相关文章

微信公众号

最新文章

更多

WebClient类方法