use of com.artipie.http.rs.RsFull in project artipie by artipie.
the class ResponseMetricsSliceTest method shouldForwardRequestUnmodified.
@Test
void shouldForwardRequestUnmodified() {
final Header header = new Header("header1", "value1");
final byte[] body = "some code".getBytes();
final RsStatus status = RsStatus.CREATED;
MatcherAssert.assertThat(new ResponseMetricsSlice((rsline, rsheaders, rsbody) -> new RsFull(status, rsheaders, rsbody), this.metrics).response(new RequestLine(RqMethod.POST, "/some_upload.war").toString(), new Headers.From(header), Flowable.just(ByteBuffer.wrap(body))), new ResponseMatcher(status, body, header));
}
use of com.artipie.http.rs.RsFull in project artipie by artipie.
the class ResponseMetricsSliceTest method shouldForwardResponseUnmodified.
@Test
void shouldForwardResponseUnmodified() {
final Header rsheader = new Header("header2", "value2");
final byte[] body = "piece of code".getBytes();
final RsStatus rsstatus = RsStatus.CREATED;
final Response response = new ResponseMetricsSlice((rsline, rsheaders, rsbody) -> new RsFull(rsstatus, new Headers.From(rsheader), Flowable.just(ByteBuffer.wrap(body))), this.metrics).response(new RequestLine(RqMethod.PUT, "/").toString(), Headers.EMPTY, Flowable.empty());
MatcherAssert.assertThat(response, new ResponseMatcher(rsstatus, body, rsheader));
}
use of com.artipie.http.rs.RsFull in project artipie by artipie.
the class PromuSlice method response.
@Override
public Response response(final String line, final Iterable<Map.Entry<String, String>> headers, final Publisher<ByteBuffer> body) {
final String ctype = new Accept(headers).values().get(0);
try (StringWriter writer = new StringWriter()) {
final MetricsOutput output = new PrometheusOutput(writer, ctype, new HashSet<>(new RqParams(new RequestLineFrom(line).uri()).values("name")));
this.metrics.publish(output);
return new RsFull(RsStatus.OK, new Headers.From(new ContentType(ctype)), new Content.From(writer.toString().getBytes(StandardCharsets.UTF_8)));
} catch (final IOException ioe) {
throw new ArtipieIOException(ioe);
}
}
Aggregations