org.apache.http.HttpResponse.containsHeader()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(143)

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

HttpResponse.containsHeader介绍

暂无

代码示例

代码示例来源:origin: rest-assured/rest-assured

public boolean containsHeader( String arg0 ) {
  return responseBase.containsHeader( arg0 );
}

代码示例来源:origin: mttkay/ignition

@Override
  public String getHeader(String header) {
    if (!response.containsHeader(header)) {
      return null;
    }
    return response.getFirstHeader(header).getValue();
  }
}

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

public void process(final HttpResponse response, final HttpContext context) 
    throws HttpException, IOException {
  if (response == null) {
    throw new IllegalArgumentException
      ("HTTP response may not be null.");
  }
  int status = response.getStatusLine().getStatusCode();
  if ((status >= HttpStatus.SC_OK) &&
    !response.containsHeader(HTTP.DATE_HEADER)) {
    String httpdate = DATE_GENERATOR.getCurrentDate();
    response.setHeader(HTTP.DATE_HEADER, httpdate); 
  }
}

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

public void process(final HttpResponse response, final HttpContext context) 
    throws HttpException, IOException {
  if (response == null) {
    throw new IllegalArgumentException("HTTP request may not be null");
  }
  if (!response.containsHeader(HTTP.SERVER_HEADER)) {
    String s = (String) response.getParams().getParameter(
        CoreProtocolPNames.ORIGIN_SERVER);
    if (s != null) {
      response.addHeader(HTTP.SERVER_HEADER, s);
    }
  }
}

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

@Test
public void shouldSupportContainsHeader() throws Exception {
 HttpResponse resp =
   new TestHttpResponse(304, "ZOMBO",
     new BasicHeader("X-Zombo-Com", "Welcome"));
 assertThat(resp.containsHeader("X-Zombo-Com")).isTrue();
 assertThat(resp.containsHeader("Location")).isFalse();
}

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

throw new IllegalArgumentException("HTTP request may not be null");
if (response.containsHeader(HTTP.TRANSFER_ENCODING)) {
  throw new ProtocolException("Transfer-encoding header already present");
if (response.containsHeader(HTTP.CONTENT_LEN)) {
  throw new ProtocolException("Content-Length header already present");
  if (entity.getContentType() != null && !response.containsHeader(
      HTTP.CONTENT_TYPE )) {
    response.addHeader(entity.getContentType()); 
  if (entity.getContentEncoding() != null && !response.containsHeader(
      HTTP.CONTENT_ENCODING)) {
    response.addHeader(entity.getContentEncoding());

代码示例来源:origin: com.jayway.restassured/rest-assured

public boolean containsHeader( String arg0 ) {
  return responseBase.containsHeader( arg0 );
}

代码示例来源:origin: com.agapsys.libs/servlet-testing-framework

/** 
 * @return a boolean indicating if response contains given header.
 * @param name header name
 * @throws IllegalArgumentException  if given name == null or name.isEmpty()
 */
public boolean containsHeader(String name) throws IllegalArgumentException {
  if (name == null || name.isEmpty())
    throw new IllegalArgumentException("Null/Empty name");
  return coreResponse.containsHeader(name);
}

代码示例来源:origin: lookfirst/sardine

@Override
  public String handleResponse(HttpResponse response) throws IOException {
    this.validateResponse(response);
    if(response.containsHeader(HttpHeaders.ETAG)) {
      return response.getFirstHeader(HttpHeaders.ETAG).getValue();
    }
    return null;
  }
}

代码示例来源:origin: com.jkoolcloud/jesl

/**
 * {@inheritDoc}
 */
@Override
public boolean containsHeader(String name) {
  return (response != null ? response.containsHeader(name) : super.containsHeader(name));
}

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

@Override
public void process(final HttpResponse response, final HttpContext context)
    throws HttpException, IOException {
  Args.notNull(response, "HTTP response");
  final int status = response.getStatusLine().getStatusCode();
  if ((status >= HttpStatus.SC_OK) &&
    !response.containsHeader(HTTP.DATE_HEADER)) {
    final String httpdate = DATE_GENERATOR.getCurrentDate();
    response.setHeader(HTTP.DATE_HEADER, httpdate);
  }
}

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

@Override
public void process(final HttpResponse response, final HttpContext context)
    throws HttpException, IOException {
  Args.notNull(response, "HTTP response");
  final int status = response.getStatusLine().getStatusCode();
  if ((status >= HttpStatus.SC_OK) &&
    !response.containsHeader(HTTP.DATE_HEADER)) {
    final String httpdate = DATE_GENERATOR.getCurrentDate();
    response.setHeader(HTTP.DATE_HEADER, httpdate);
  }
}

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

@Override
public void process(final HttpResponse response, final HttpContext context)
    throws HttpException, IOException {
  Args.notNull(response, "HTTP response");
  if (!response.containsHeader(HTTP.SERVER_HEADER)) {
    if (this.originServer != null) {
      response.addHeader(HTTP.SERVER_HEADER, this.originServer);
    }
  }
}

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

@Override
public void process(final HttpResponse response, final HttpContext context)
    throws HttpException, IOException {
  Args.notNull(response, "HTTP response");
  if (!response.containsHeader(HTTP.SERVER_HEADER)) {
    if (this.originServer != null) {
      response.addHeader(HTTP.SERVER_HEADER, this.originServer);
    }
  }
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.apache.httpcomponents.httpcore

public void process(final HttpResponse response, final HttpContext context)
    throws HttpException, IOException {
  Args.notNull(response, "HTTP response");
  if (!response.containsHeader(HTTP.SERVER_HEADER)) {
    if (this.originServer != null) {
      response.addHeader(HTTP.SERVER_HEADER, this.originServer);
    }
  }
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

@Override
public void process(final HttpResponse response, final HttpContext context)
    throws HttpException, IOException {
  Args.notNull(response, "HTTP response");
  if (!response.containsHeader(HTTP.SERVER_HEADER)) {
    if (this.originServer != null) {
      response.addHeader(HTTP.SERVER_HEADER, this.originServer);
    }
  }
}

代码示例来源:origin: Nextdoor/bender

@Override
public void process(final HttpResponse response, final HttpContext context)
    throws HttpException, IOException {
  Args.notNull(response, "HTTP response");
  final int status = response.getStatusLine().getStatusCode();
  if ((status >= HttpStatus.SC_OK) &&
    !response.containsHeader(HTTP.DATE_HEADER)) {
    final String httpdate = DATE_GENERATOR.getCurrentDate();
    response.setHeader(HTTP.DATE_HEADER, httpdate);
  }
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.apache.httpcomponents.httpcore

public void process(final HttpResponse response, final HttpContext context)
    throws HttpException, IOException {
  Args.notNull(response, "HTTP response");
  final int status = response.getStatusLine().getStatusCode();
  if ((status >= HttpStatus.SC_OK) &&
    !response.containsHeader(HTTP.DATE_HEADER)) {
    final String httpdate = DATE_GENERATOR.getCurrentDate();
    response.setHeader(HTTP.DATE_HEADER, httpdate);
  }
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

@Override
public void process(final HttpResponse response, final HttpContext context)
    throws HttpException, IOException {
  Args.notNull(response, "HTTP response");
  final int status = response.getStatusLine().getStatusCode();
  if ((status >= HttpStatus.SC_OK) &&
    !response.containsHeader(HTTP.DATE_HEADER)) {
    final String httpdate = DATE_GENERATOR.getCurrentDate();
    response.setHeader(HTTP.DATE_HEADER, httpdate);
  }
}

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

public void process(final HttpResponse response, final HttpContext context) 
    throws HttpException, IOException {
  if (response == null) {
    throw new IllegalArgumentException("HTTP request may not be null");
  }
  if (!response.containsHeader(HTTP.SERVER_HEADER)) {
    String s = (String) response.getParams().getParameter(
        CoreProtocolPNames.ORIGIN_SERVER);
    if (s != null) {
      response.addHeader(HTTP.SERVER_HEADER, s);
    }
  }
}

相关文章