本文整理了Java中com.hotels.styx.api.HttpResponse.version()
方法的一些代码示例,展示了HttpResponse.version()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpResponse.version()
方法的具体详情如下:
包路径:com.hotels.styx.api.HttpResponse
类名称:HttpResponse
方法名:version
暂无
代码示例来源:origin: HotelsDotCom/styx
/**
* Creates a new {@link Builder} object from an existing {@link LiveHttpResponse} object.
* Similar to {@link this.newBuilder} method.
*
* @param response a full HTTP response instance
*/
public Builder(HttpResponse response) {
this.status = response.status();
this.version = response.version();
this.headers = response.headers().newBuilder();
this.body = response.body();
}
代码示例来源:origin: com.hotels.styx/styx-api
public Builder(HttpResponse response, byte[] encodedBody) {
this.status = statusWithCode(response.status().code());
this.version = httpVersion(response.version().toString());
this.headers = response.headers().newBuilder();
this.body = encodedBody;
this.cookies = new ArrayList<>(response.cookies());
}
代码示例来源:origin: com.hotels.styx/styx-api
public Builder(HttpResponse response, Observable<ByteBuf> decoded) {
this.status = statusWithCode(response.status().code());
this.version = httpVersion(response.version().toString());
this.headers = response.headers().newBuilder();
this.body = decoded;
this.cookies = new ArrayList<>(response.cookies());
}
代码示例来源:origin: HotelsDotCom/styx
@Test
public void createsAResponseWithDefaultValues() {
HttpResponse response = HttpResponse.response().build();
assertThat(response.version(), is(HTTP_1_1));
assertThat(response.cookies(), is(emptyIterable()));
assertThat(response.headers(), is(emptyIterable()));
assertThat(response.body().length, is(0));
}
代码示例来源:origin: HotelsDotCom/styx
/**
* Creates a new {@link Builder} object from a response code and a content stream.
* <p>
* Builder's response status line parameters and the HTTP headers are populated from
* the given {@code response} object, but the content stream is set to {@code ByteStream}.
*
* @param response a full response for which the builder is based on
* @param byteStream a content byte stream
*/
public Builder(HttpResponse response, ByteStream byteStream) {
this.status = statusWithCode(response.status().code());
this.version = httpVersion(response.version().toString());
this.headers = response.headers().newBuilder();
this.body = requireNonNull(byteStream);
}
代码示例来源:origin: HotelsDotCom/styx
@Test
public void createsResponseWithMinimalInformation() {
HttpResponse response = HttpResponse.response()
.status(BAD_GATEWAY)
.version(HTTP_1_1)
.build();
assertThat(response.status(), is(BAD_GATEWAY));
assertThat(response.version(), is(HTTP_1_1));
assertThat(response.cookies(), is(emptyIterable()));
assertThat(response.headers(), is(emptyIterable()));
assertThat(response.body().length, is(0));
}
代码示例来源:origin: HotelsDotCom/styx
@Test
public void encodesToFullHttpResponse() {
LiveHttpResponse response = response(CREATED)
.version(HTTP_1_0)
.header("HeaderName", "HeaderValue")
.cookies(responseCookie("CookieName", "CookieValue").build())
.body(new ByteStream(Flux.just("foo", "bar").map(it -> new Buffer(copiedBuffer(it, UTF_8)))))
.build();
HttpResponse full = Mono.from(response.aggregate(0x1000)).block();
assertThat(full.status(), is(CREATED));
assertThat(full.version(), is(HTTP_1_0));
assertThat(full.headers(), containsInAnyOrder(header("HeaderName", "HeaderValue"), header("Set-Cookie", "CookieName=CookieValue")));
assertThat(full.cookies(), contains(responseCookie("CookieName", "CookieValue").build()));
assertThat(full.body(), is(bytes("foobar")));
}
内容来源于网络,如有侵权,请联系作者删除!