Skip to content

Commit

Permalink
Replace httpServerRequest.absoluteURI() with simple URI check in Root…
Browse files Browse the repository at this point in the history
… Handler

This is done because the check doesn't actually need the entire
absoluteURI, it just needs to make sure that the URI is correct.
The use of absoluteURI incurs a small performance penalty
(which can be seen in flame graphs).
  • Loading branch information
geoand committed Feb 25, 2021
1 parent 28991de commit bc25d4b
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
Expand Down Expand Up @@ -129,7 +131,10 @@ public class VertxHttpRecorder {
private static final Handler<HttpServerRequest> ACTUAL_ROOT = new Handler<HttpServerRequest>() {
@Override
public void handle(HttpServerRequest httpServerRequest) {
if (httpServerRequest.absoluteURI() == null) {
try {
// we simply need to know if the URI is valid
new URI(httpServerRequest.uri());
} catch (URISyntaxException e) {
httpServerRequest.response().setStatusCode(400).end();
return;
}
Expand Down

0 comments on commit bc25d4b

Please sign in to comment.