io.restassured.response.Response.getHeaders()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(5.6k)|赞(0)|评价(0)|浏览(228)

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

Response.getHeaders介绍

暂无

代码示例

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

private List<Cookie> extractResponseCookies(Response response, CookieOrigin cookieOrigin) {
  List<Cookie> cookies = new ArrayList<Cookie>();
  for (String cookieValue : response.getHeaders().getValues("Set-Cookie")) {
    Header setCookieHeader = new BasicHeader("Set-Cookie", cookieValue);
    try {
      cookies.addAll(cookieSpec.parse(setCookieHeader, cookieOrigin));
    } catch (MalformedCookieException ignored) {
    }
  }
  return cookies;
}

代码示例来源:origin: spring-projects/spring-restdocs

private HttpHeaders extractHeaders(Response response) {
  HttpHeaders httpHeaders = new HttpHeaders();
  for (Header header : response.getHeaders()) {
    httpHeaders.add(header.getName(), header.getValue());
  }
  return httpHeaders;
}

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

/**
 * Clone an already existing response.
 *
 * @return Builder.
 */
public ResponseBuilder clone(Response response) {
  if (isRestAssuredResponse(response)) {
    final RestAssuredResponseImpl raResponse = raResponse(response);
    restAssuredResponse.setContent(raResponse.getContent());
    restAssuredResponse.setHasExpectations(raResponse.getHasExpectations());
    restAssuredResponse.setDefaultContentType(raResponse.getDefaultContentType());
    restAssuredResponse.setDecoderConfig(raResponse.getDecoderConfig());
    restAssuredResponse.setSessionIdName(raResponse.getSessionIdName());
    restAssuredResponse.setConnectionManager(raResponse.getConnectionManager());
    restAssuredResponse.setConfig(raResponse.getConfig());
    restAssuredResponse.setRpr(raResponse.getRpr());
    restAssuredResponse.setLogRepository(raResponse.getLogRepository());
    restAssuredResponse.setFilterContextProperties(raResponse.getFilterContextProperties());
  } else {
    restAssuredResponse.setContent(response.asInputStream());
  }
  restAssuredResponse.setContentType(response.getContentType());
  restAssuredResponse.setCookies(response.getDetailedCookies());
  restAssuredResponse.setResponseHeaders(response.getHeaders());
  restAssuredResponse.setStatusCode(response.getStatusCode());
  restAssuredResponse.setStatusLine(response.getStatusLine());
  return this;
}

代码示例来源:origin: guru.nidi.raml/raml-tester

@Override
public Values getHeaderValues() {
  return headersToValues(response.getHeaders());
}

代码示例来源:origin: nidi3/raml-tester

@Override
public Values getHeaderValues() {
  return headersToValues(response.getHeaders());
}

代码示例来源:origin: epam/JDI

public List<Header> headers() { return raResponse.getHeaders().asList(); }
public String cookie(String name) { return raResponse.getCookie(name); }

代码示例来源:origin: com.atlassian.oai/swagger-request-validator-restassured

/**
   * Builds a {@link Response} for the OpenAPI validator out of the
   * original {@link io.restassured.response.Response}.
   *
   * @param originalResponse the original {@link io.restassured.response.Response}
   */
  @Nonnull
  public static Response of(@Nonnull final io.restassured.response.Response originalResponse) {
    requireNonNull(originalResponse, "An original response is required");
    final SimpleResponse.Builder builder = new SimpleResponse.Builder(originalResponse.getStatusCode())
        .withBody(originalResponse.getBody().asString());
    if (originalResponse.getHeaders() != null) {
      originalResponse.getHeaders().forEach(header -> builder.withHeader(header.getName(), header.getValue()));
    }
    return builder.build();
  }
}

代码示例来源:origin: lv.ctco.cukes/cukes-http

private void cacheHeaders(Response response) {
  clearOldHeaders();
  Headers headers = response.getHeaders();
  for (Header header : headers) {
    String headerName = CukesOptions.HEADER_PREFIX + header.getName();
    world.put(headerName, header.getValue());
  }
}

代码示例来源:origin: ctco/cukes

private void cacheHeaders(Response response) {
  clearOldHeaders();
  Headers headers = response.getHeaders();
  for (Header header : headers) {
    String headerName = CukesOptions.HEADER_PREFIX + header.getName();
    world.put(headerName, header.getValue());
  }
}

代码示例来源:origin: org.bitbucket.iamkenos/cissnei-rest

private void logResponse(Response response) {
  StringBuilder builder = new StringBuilder("RESPONSE:\n\n");
  String body = response.getBody().prettyPrint();
  createLog(builder, "STATUS", String.valueOf(response.getStatusCode()), false);
  createLog(builder, "HEADERS", response.getHeaders().toString(), true);
  if (body.length() > 0) createLog(builder, "BODY", response.getBody().prettyPrint(), true);
  scenarioWrite(builder.toString());
}

代码示例来源:origin: HotelsDotCom/heat

logUtils.debug("header name '{}'", headerName);
List<Header> headers = ((Response) responses).getHeaders().getList(headerName);
isCheckOk &= assertionHandler.assertion(isBlocking, "assertEquals", logUtils.getTestCaseDetails() + "check on header '" + headerName + "'-- ",
    headerExpectedValues.size(), headers.size());

代码示例来源:origin: com.hotels/heat-core-utils

logUtils.debug("header name '{}'", headerName);
List<Header> headers = ((Response) responses).getHeaders().getList(headerName);
isCheckOk &= assertionHandler.assertion(isBlocking, "assertEquals", logUtils.getTestCaseDetails() + "check on header '" + headerName + "'-- ",
    headerExpectedValues.size(), headers.size());

代码示例来源:origin: com.adobe.ride/ride-core

+ System.lineSeparator() + System.lineSeparator() + "RESPONSE: "
+ System.lineSeparator() + " " + response.getStatusLine() + System.lineSeparator()
+ getHeaderString(response.getHeaders()) + System.lineSeparator()
+ getBodyString(response.getBody(), "response") + System.lineSeparator()
+ "SPLUNK SEARCH: " + getSplunkSearchString(splunkEndPoint, requestID)

相关文章