Skip to content

Commit f65d988

Browse files
committed
Follow the Common Log Format in access logs for HTTP version when 'H' is used
Fixes: quarkusio#48122
1 parent db50b6e commit f65d988

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/attribute/RequestLineAttribute.java

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import io.quarkus.vertx.http.runtime.filters.OriginalRequestContext;
44
import io.vertx.core.http.HttpMethod;
5-
import io.vertx.core.http.HttpVersion;
65
import io.vertx.ext.web.RoutingContext;
76

87
/**
@@ -40,23 +39,7 @@ public String readAttribute(final RoutingContext exchange) {
4039
uri = exchange.request().uri();
4140
}
4241

43-
return httpMethod + " " + uri + " " + getHttpVersionStr(exchange.request().version());
44-
}
45-
46-
private static String getHttpVersionStr(HttpVersion version) {
47-
// best effort to try and infer the HTTP version from
48-
// any "unknown" enum value
49-
return switch (version) {
50-
case HTTP_1_0 -> "HTTP/1.0";
51-
case HTTP_1_1 -> "HTTP/1.1";
52-
case HTTP_2 -> "HTTP/2";
53-
default ->
54-
// best effort to try and infer the HTTP version from
55-
// any "unknown" enum value
56-
version.name()
57-
.replace("HTTP_", "HTTP/")
58-
.replace("_", ".");
59-
};
42+
return httpMethod + " " + uri + " " + RequestProtocolAttribute.getHttpVersionStr(exchange.request().version());
6043
}
6144

6245
@Override

extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/attribute/RequestProtocolAttribute.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.quarkus.vertx.http.runtime.attribute;
22

3+
import io.vertx.core.http.HttpVersion;
34
import io.vertx.ext.web.RoutingContext;
45

56
/**
@@ -19,14 +20,30 @@ private RequestProtocolAttribute() {
1920

2021
@Override
2122
public String readAttribute(final RoutingContext exchange) {
22-
return exchange.request().version().name();
23+
return getHttpVersionStr(exchange.request().version());
2324
}
2425

2526
@Override
2627
public void writeAttribute(final RoutingContext exchange, final String newValue) throws ReadOnlyAttributeException {
2728
throw new ReadOnlyAttributeException("Request getProtocol", newValue);
2829
}
2930

31+
static String getHttpVersionStr(HttpVersion version) {
32+
// best effort to try and infer the HTTP version from
33+
// any "unknown" enum value
34+
return switch (version) {
35+
case HTTP_1_0 -> "HTTP/1.0";
36+
case HTTP_1_1 -> "HTTP/1.1";
37+
case HTTP_2 -> "HTTP/2";
38+
default ->
39+
// best effort to try and infer the HTTP version from
40+
// any "unknown" enum value
41+
version.name()
42+
.replace("HTTP_", "HTTP/")
43+
.replace("_", ".");
44+
};
45+
}
46+
3047
public static final class Builder implements ExchangeAttributeBuilder {
3148

3249
@Override

0 commit comments

Comments
 (0)