use of com.artipie.http.rs.RsWithStatus in project maven-adapter by artipie.
the class HeadProxySlice method response.
@Override
public Response response(final String line, final Iterable<Map.Entry<String, String>> headers, final Publisher<ByteBuffer> body) {
final CompletableFuture<Response> promise = new CompletableFuture<>();
this.client.response(line, Headers.EMPTY, Content.EMPTY).send((status, rsheaders, rsbody) -> {
promise.complete(new RsWithHeaders(new RsWithStatus(status), rsheaders));
return CompletableFuture.allOf();
});
return new AsyncResponse(promise);
}
use of com.artipie.http.rs.RsWithStatus in project artipie by artipie.
the class ResponseMetricsSliceTest method shouldReportNoAuthResponse.
@Test
public void shouldReportNoAuthResponse() {
this.send(RqMethod.PUT, new RsWithStatus(RsStatus.UNAUTHORIZED));
this.send(RqMethod.PUT, new RsWithStatus(RsStatus.UNAUTHORIZED));
MatcherAssert.assertThat(this.metrics.counter("put.error.no-auth").value(), new IsEqual<>(2L));
}
use of com.artipie.http.rs.RsWithStatus in project artipie by artipie.
the class ResponseMetricsSliceTest method shouldReportBadAuthResponse.
@Test
public void shouldReportBadAuthResponse() {
this.send(RqMethod.DELETE, new Headers.From(new Authorization("some value")), new RsWithStatus(RsStatus.UNAUTHORIZED));
this.send(RqMethod.DELETE, new Headers.From(new Authorization("another value")), new RsWithStatus(RsStatus.UNAUTHORIZED));
MatcherAssert.assertThat(this.metrics.counter("delete.error.bad-auth").value(), new IsEqual<>(2L));
}
use of com.artipie.http.rs.RsWithStatus in project artipie by artipie.
the class ContentLengthRestrictionTest method shouldPassRequestsWithinLimit.
@ParameterizedTest
@CsvSource({ "10,0", "10,not number", "10,1", "10,10" })
public void shouldPassRequestsWithinLimit(final int limit, final String value) {
final Slice slice = new ContentLengthRestriction((line, headers, body) -> new RsWithStatus(RsStatus.OK), limit);
final Response response = slice.response("", this.headers(value), Flowable.empty());
MatcherAssert.assertThat(response, new RsHasStatus(RsStatus.OK));
}
use of com.artipie.http.rs.RsWithStatus in project artipie by artipie.
the class ContentLengthRestrictionTest method shouldPassRequestsWithoutContentLength.
@Test
public void shouldPassRequestsWithoutContentLength() {
final int limit = 10;
final Slice slice = new ContentLengthRestriction((line, headers, body) -> new RsWithStatus(RsStatus.OK), limit);
final Response response = slice.response("", Collections.emptySet(), Flowable.empty());
MatcherAssert.assertThat(response, new RsHasStatus(RsStatus.OK));
}
Aggregations