org.apache.http.client.methods.CloseableHttpResponse.setHeader()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(3.2k)|赞(0)|评价(0)|浏览(236)

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

CloseableHttpResponse.setHeader介绍

暂无

代码示例

代码示例来源:origin: org.apache.sling/org.apache.sling.testing.clients

@Override
public void setHeader(Header header) {
  httpResponse.setHeader(header);
}

代码示例来源:origin: org.apache.sling/org.apache.sling.testing.clients

@Override
public void setHeader(String name, String value) {
  httpResponse.setHeader(name, value);
}

代码示例来源:origin: com.machinepublishers/jbrowserdriver

public void setContentLength(long contentLength) {
 this.contentLength.set(contentLength);
 response.get().setHeader("Content-Length", Long.toString(contentLength));
}

代码示例来源:origin: com.machinepublishers/jbrowserdriver

if (response.get() != null && response.get().getEntity() != null) {
 entity.set(response.get().getEntity());
 response.get().setHeader("Cache-Control", "no-store, no-cache");
    String path = uri.getPath();
    path = StringUtils.isEmpty(path) ? "/" : path;
    response.get().setHeader("Location",
      new URIBuilder(location).setPath(path).setFragment(this.urlFragment).build().toString());
    int fromIndex = location.indexOf("//") + 2;
    if (fromIndex <= location.length() && location.substring(fromIndex).contains("/")) {
     response.get().setHeader("Location", location + "#" + this.urlFragment);
    } else {
     response.get().setHeader("Location", location + "/#" + this.urlFragment);

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

response.removeHeaders("Cache-control");
response.removeHeaders("Expires");
response.setHeader("Date", DateUtils.formatDate(new Date(System.currentTimeMillis())));
response.setHeader("Cache-control", "public, max-age=" + ttl);
response.setHeader("Expires",
    DateUtils.formatDate(new Date(System.currentTimeMillis() + ((long) ttl) * 1000)));

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

e.getHttpResponse().setHeader(H_X_ENABLED_CAPABILITIES, join(enabledCapabilities, " "));
e.getHttpResponse().setHeader(H_X_NEXT_SURROGATE_CONTROL, join(newSurrogateControlL, ", "));
  e.getHttpResponse().setHeader("Cache-Control", join(newCacheContent, ", "));

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

@Override
public boolean event(EventDefinition arg0, Event arg1) {
  FetchEvent fe = (FetchEvent) arg1;
  Header contentTypeHeader = fe.getHttpResponse().getFirstHeader("Content-Type");
  // No content type, there is nothing we can do
  if (contentTypeHeader == null) {
    return true;
  }
  String contentType = contentTypeHeader.getValue();
  // Charset is present -> OK
  if (StringUtils.containsIgnoreCase(contentType, "charset")) {
    return true;
  }
  // Is document parsable
  boolean parsable = false;
  for (String parseableContentType : parsableContentTypes) {
    if (StringUtils.containsIgnoreCase(contentType, parseableContentType)) {
      parsable = true;
      break;
    }
  }
  // Add default charset
  if (parsable) {
    fe.getHttpResponse().setHeader("Content-Type", contentType + "; charset=" + defaultCharset);
  }
  return true;
}

相关文章