Skip to content
Open
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 @@ -103,7 +103,7 @@ public ServerHttpRequest.Builder path(String path) {
}

@Override
public ServerHttpRequest.Builder contextPath(String contextPath) {
public ServerHttpRequest.Builder contextPath(@Nullable String contextPath) {
this.contextPath = contextPath;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,10 @@ interface Builder {
* contextPath} and it must match the start of the path of the URI of
* the request. That means changing the contextPath, implies also
* changing the path via {@link #path(String)}.
* <p>The given value may be {@code null} or empty to indicate there
* is no context path.
*/
Builder contextPath(String contextPath);
Builder contextPath(@Nullable String contextPath);

/**
* Set or override the specified header values under the given name.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,16 @@ void mutateWithExistingContextPath() throws Exception {
assertThat(mutated.getURI().getRawPath()).isEqualTo("/other/path");
}

@Test
void mutateContextPathToNull() throws Exception {
ServerHttpRequest request = createRequest("/context/path", "/context");

ServerHttpRequest mutated = request.mutate().contextPath(null).build();
assertThat(mutated.getPath().contextPath().value()).isEmpty();
assertThat(mutated.getPath().pathWithinApplication().value()).isEqualTo("/context/path");
assertThat(mutated.getURI().getRawPath()).isEqualTo("/context/path");
}

@Test
void mutateContextPathWithoutUpdatingPathShouldFail() throws Exception {
ServerHttpRequest request = createRequest("/context/path", "/context");
Expand Down