Skip to content
This repository was archived by the owner on Mar 24, 2026. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@
public class PlaintextResource {
private static final String HELLO_WORLD = "Hello, world!";
private static final Buffer HELLO_WORLD_BUFFER = Buffer.buffer(HELLO_WORLD, "UTF-8");
private static final CharSequence HELLO_WORLD_LENGTH = HttpHeaders.createOptimized("" + HELLO_WORLD.length());

@Route(path = "plaintext")
public void plaintext(final RoutingContext rc) {
final var response = rc.response();
final var headers = response.headers();
headers.add(HttpHeaders.CONTENT_TYPE, HttpHeaderValues.TEXT_PLAIN);
headers.add(HttpHeaders.CONTENT_LENGTH, HELLO_WORLD_LENGTH);
response.end(HELLO_WORLD_BUFFER, null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@
public class PlaintextHttpHandler {
private static final String HELLO_WORLD = "Hello, world!";
private static final Buffer HELLO_WORLD_BUFFER = Buffer.buffer(HELLO_WORLD, "UTF-8");
private static final CharSequence HELLO_WORLD_LENGTH = HttpHeaders.createOptimized("" + HELLO_WORLD.length());

public void handle(final HttpServerRequest request) {
final HttpServerResponse response = request.response();
final MultiMap headers = response.headers();
headers.add(HttpHeaders.CONTENT_LENGTH, HELLO_WORLD_LENGTH);
headers.add(HttpHeaders.CONTENT_TYPE, HttpHeaderValues.TEXT_PLAIN);
response.end(HELLO_WORLD_BUFFER, null);
}
Expand Down
Loading