Initialize RequestPath on demand

Closes gh-33227
This commit is contained in:
rstoyanchev
2024-07-17 15:15:19 +01:00
parent 30a64d6a0b
commit b9509d3c85
2 changed files with 11 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -50,7 +50,11 @@ public abstract class AbstractServerHttpRequest implements ServerHttpRequest {
private final URI uri;
private final RequestPath path;
@Nullable
private final String contextPath;
@Nullable
private RequestPath path;
private final HttpHeaders headers;
@@ -92,7 +96,7 @@ public abstract class AbstractServerHttpRequest implements ServerHttpRequest {
this.method = method;
this.uri = uri;
this.path = RequestPath.parse(uri, contextPath);
this.contextPath = contextPath;
this.headers = HttpHeaders.readOnlyHttpHeaders(headers);
}
@@ -140,6 +144,9 @@ public abstract class AbstractServerHttpRequest implements ServerHttpRequest {
@Override
public RequestPath getPath() {
if (this.path == null) {
this.path = RequestPath.parse(this.uri, this.contextPath);
}
return this.path;
}