org.mockserver.model.HttpResponse.withHeaders()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(75)

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

HttpResponse.withHeaders介绍

[英]The headers to return as a list of Header objects
[中]要作为标题对象列表返回的标题

代码示例

代码示例来源:origin: jamesdbloom/mockserver

private void setHeaders(HttpResponse httpResponse, FullHttpResponse fullHttpResponse) {
  Headers headers = new Headers();
  for (String headerName : fullHttpResponse.headers().names()) {
    headers.withEntry(new Header(headerName, fullHttpResponse.headers().getAll(headerName)));
  }
  if (!headers.isEmpty()) {
    httpResponse.withHeaders(headers);
  }
}

代码示例来源:origin: jamesdbloom/mockserver

response()
  .withStatusCode(request.getPath().equalsIgnoreCase("/not_found") ? NOT_FOUND.code() : OK.code())
  .withHeaders(request.getHeaderList());

代码示例来源:origin: jamesdbloom/mockserver

httpResponse.withHeaders(headers);
  return httpResponse;
} catch (Exception ex) {

代码示例来源:origin: jamesdbloom/mockserver

public HttpResponse buildObject() {
  return new HttpResponse()
    .withStatusCode(statusCode)
    .withReasonPhrase(reasonPhrase)
    .withBody(body != null ? body.buildObject() : null)
    .withHeaders(headers)
    .withCookies(cookies)
    .withDelay((delay != null ? delay.buildObject() : null))
    .withConnectionOptions((connectionOptions != null ? connectionOptions.buildObject() : null));
}

代码示例来源:origin: jamesdbloom/mockserver

public HttpResponse clone() {
    return response()
      .withStatusCode(statusCode)
      .withReasonPhrase(reasonPhrase)
      .withBody(body)
      .withHeaders(headers.clone())
      .withCookies(cookies.clone())
      .withDelay(getDelay())
      .withConnectionOptions(connectionOptions);
  }
}

代码示例来源:origin: jamesdbloom/mockserver

.withStatusCode(OK_200.code())
  .withReasonPhrase(OK_200.reasonPhrase())
  .withHeaders(
    header(CONTENT_TYPE.toString(), MediaType.PNG.toString()),
    header(CONTENT_DISPOSITION.toString(), "form-data; name=\"test.png\"; filename=\"test.png\"")
.withStatusCode(OK_200.code())
.withReasonPhrase(OK_200.reasonPhrase())
.withHeaders(
  header(CONTENT_DISPOSITION.toString(), "form-data; name=\"test.png\"; filename=\"test.png\""),
  header(CONTENT_TYPE.toString(), MediaType.PNG.toString())
.withStatusCode(OK_200.code())
.withReasonPhrase(OK_200.reasonPhrase())
.withHeaders(
  header(CONTENT_DISPOSITION.toString(), "form-data; name=\"test.png\"; filename=\"test.png\""),
  header(CONTENT_TYPE.toString(), MediaType.PNG.toString())

代码示例来源:origin: jamesdbloom/mockserver

.withStatusCode(OK_200.code())
  .withReasonPhrase(OK_200.reasonPhrase())
  .withHeaders(
    header(CONTENT_TYPE.toString(), MediaType.PNG.toString()),
    header(CONTENT_DISPOSITION.toString(), "form-data; name=\"test.png\"; filename=\"test.png\"")
.withStatusCode(OK_200.code())
.withReasonPhrase(OK_200.reasonPhrase())
.withHeaders(
  header(CONTENT_DISPOSITION.toString(), "form-data; name=\"test.png\"; filename=\"test.png\""),
  header(CONTENT_TYPE.toString(), MediaType.PNG.toString())
.withStatusCode(OK_200.code())
.withReasonPhrase(OK_200.reasonPhrase())
.withHeaders(
  header(CONTENT_DISPOSITION.toString(), "form-data; name=\"test.png\"; filename=\"test.png\""),
  header(CONTENT_TYPE.toString(), MediaType.PNG.toString())

代码示例来源:origin: jamesdbloom/mockserver

.withStatusCode(OK_200.code())
  .withReasonPhrase(OK_200.reasonPhrase())
  .withHeaders(
    header(CONTENT_TYPE.toString(), MediaType.PDF.toString()),
    header(CONTENT_DISPOSITION.toString(), "form-data; name=\"test.pdf\"; filename=\"test.pdf\""),
.withStatusCode(OK_200.code())
.withReasonPhrase(OK_200.reasonPhrase())
.withHeaders(
  header(CONTENT_DISPOSITION.toString(), "form-data; name=\"test.pdf\"; filename=\"test.pdf\""),
  header(CACHE_CONTROL.toString(), "must-revalidate, post-check=0, pre-check=0"),
.withStatusCode(OK_200.code())
.withReasonPhrase(OK_200.reasonPhrase())
.withHeaders(
  header(CONTENT_DISPOSITION.toString(), "form-data; name=\"test.pdf\"; filename=\"test.pdf\""),
  header(CACHE_CONTROL.toString(), "must-revalidate, post-check=0, pre-check=0"),

代码示例来源:origin: oblac/jodd

.withHeaders(
  new Header(HttpHeaders.Names.CONTENT_TYPE,"application/json")

代码示例来源:origin: jamesdbloom/mockserver

.withReasonPhrase(HttpStatusCode.ACCEPTED_202.reasonPhrase())
    .withBody("some_body_response")
    .withHeaders(header("headerNameResponse", "headerValueResponse"))
);
  .withReasonPhrase(HttpStatusCode.ACCEPTED_202.reasonPhrase())
  .withBody("some_body_response")
  .withHeaders(
    header("headerNameResponse", "headerValueResponse")
  ),
  .withReasonPhrase(HttpStatusCode.ACCEPTED_202.reasonPhrase())
  .withBody("some_body_response")
  .withHeaders(
    header("headerNameResponse", "headerValueResponse")
  ),

代码示例来源:origin: jamesdbloom/mockserver

.withStatusCode(HttpStatusCode.ACCEPTED_202.code())
.withReasonPhrase(HttpStatusCode.ACCEPTED_202.reasonPhrase())
.withHeaders(
  header("x-callback", "test_callback_header")
.withStatusCode(HttpStatusCode.ACCEPTED_202.code())
.withReasonPhrase(HttpStatusCode.ACCEPTED_202.reasonPhrase())
.withHeaders(
  header("x-callback", "test_callback_header")

代码示例来源:origin: jamesdbloom/mockserver

.withStatusCode(OK_200.code())
.withReasonPhrase(OK_200.reasonPhrase())
.withHeaders(
  header("x-test", "test_headers_and_body")
.withStatusCode(OK_200.code())
.withReasonPhrase(OK_200.reasonPhrase())
.withHeaders(
  header("x-test", "test_headers_and_body")

代码示例来源:origin: jamesdbloom/mockserver

.withStatusCode(OK_200.code())
.withReasonPhrase(OK_200.reasonPhrase())
.withHeaders(
  header("x-test", "test_headers_and_body")
.withStatusCode(OK_200.code())
.withReasonPhrase(OK_200.reasonPhrase())
.withHeaders(
  header("x-test", "test_headers_and_body")

代码示例来源:origin: jamesdbloom/mockserver

.withBody("some_body_response")
.withCookies(cookie("cookieNameResponse", "cookieValueResponse"))
.withHeaders(
  header(SET_COOKIE.toString(), "cookieNameResponse=cookieValueResponse")
),
.withBody("some_body_response")
.withCookies(cookie("cookieNameResponse", "cookieValueResponse"))
.withHeaders(
  header(SET_COOKIE.toString(), "cookieNameResponse=cookieValueResponse")
),

代码示例来源:origin: jamesdbloom/mockserver

.withReasonPhrase(HttpStatusCode.ACCEPTED_202.reasonPhrase())
    .withBody("some_body_response")
    .withHeaders(header("headerNameResponse", "headerValueResponse"))
    .withCookies(cookie("cookieNameResponse", "cookieValueResponse"))
);

代码示例来源:origin: jamesdbloom/mockserver

.withReasonPhrase(HttpStatusCode.ACCEPTED_202.reasonPhrase())
    .withBody("some_body_response")
    .withHeaders(header("headerNameResponse", "headerValueResponse"))
    .withCookies(cookie("cookieNameResponse", "cookieValueResponse"))
);

代码示例来源:origin: jamesdbloom/mockserver

.withReasonPhrase(HttpStatusCode.ACCEPTED_202.reasonPhrase())
    .withBody("some_body_response")
    .withHeaders(header("headerNameResponse", "headerValueResponse"))
    .withCookies(cookie("cookieNameResponse", "cookieValueResponse"))
);

代码示例来源:origin: jamesdbloom/mockserver

.withReasonPhrase(HttpStatusCode.ACCEPTED_202.reasonPhrase())
    .withBody("some_body")
    .withHeaders(header("headerName", "headerValue"))
    .withCookies(cookie("cookieName", "cookieValue"))
);

代码示例来源:origin: jamesdbloom/mockserver

.withReasonPhrase(HttpStatusCode.ACCEPTED_202.reasonPhrase())
    .withBody("some_body")
    .withHeaders(header("headerName", "headerValue"))
    .withCookies(cookie("cookieName", "cookieValue"))
);

代码示例来源:origin: jamesdbloom/mockserver

.withReasonPhrase(HttpStatusCode.ACCEPTED_202.reasonPhrase())
    .withBody("some_body")
    .withHeaders(header("headerName", "headerValue"))
    .withCookies(cookie("cookieName", "cookieValue"))
);

相关文章