Handle requests when the host header is not specified at all correctly. (#901)

Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
pull/909/head
Adrian Sutton 5 years ago committed by GitHub
parent b87a6358a2
commit f2244ee531
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      metrics/core/src/main/java/org/hyperledger/besu/metrics/prometheus/MetricsHttpService.java

@ -149,7 +149,11 @@ class MetricsHttpService implements MetricsService {
}
private Optional<String> getAndValidateHostHeader(final RoutingContext event) {
final Iterable<String> splitHostHeader = Splitter.on(':').split(event.request().host());
final String hostHeader = event.request().host();
if (hostHeader == null) {
return Optional.empty();
}
final Iterable<String> splitHostHeader = Splitter.on(':').split(hostHeader);
final long hostPieces = stream(splitHostHeader).count();
if (hostPieces > 1) {
// If the host contains a colon, verify the host is correctly formed - host [ ":" port ]

Loading…
Cancel
Save