Skip to content

Commit

Permalink
Change
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim-Brooks committed Sep 19, 2024
1 parent 00e81de commit 46dd1fd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
13 changes: 13 additions & 0 deletions server/src/main/java/org/elasticsearch/http/HttpPreRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,19 @@ public interface HttpPreRequest {
*/
String uri();

/**
* The uri without the query string.
*/
default String path() {
String uri = uri();
final int index = uri.indexOf('?');
if (index >= 0) {
return uri.substring(0, index);
} else {
return uri;
}
}

/**
* Get all of the headers and values associated with the HTTP headers.
* Modifications of this map are not supported.
Expand Down
11 changes: 1 addition & 10 deletions server/src/main/java/org/elasticsearch/rest/RestRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ void ensureSafeBuffers() {
*/
public static RestRequest request(XContentParserConfiguration parserConfig, HttpRequest httpRequest, HttpChannel httpChannel) {
Map<String, String> params = params(httpRequest.uri());
String path = path(httpRequest.uri());
String path = httpRequest.path();
return new RestRequest(
parserConfig,
params,
Expand All @@ -229,15 +229,6 @@ private static Map<String, String> params(final String uri) {
return params;
}

private static String path(final String uri) {
final int index = uri.indexOf('?');
if (index >= 0) {
return uri.substring(0, index);
} else {
return uri;
}
}

/**
* Creates a new REST request. The path is not decoded so this constructor will not throw a
* {@link BadParameterException}.
Expand Down

0 comments on commit 46dd1fd

Please sign in to comment.