-
Notifications
You must be signed in to change notification settings - Fork 2.1k
App Config - Query Param Ordering #46665
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 11 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
30c39e1
SortsQueryParams
mrm9084 2a863f2
Update CHANGELOG.md
mrm9084 c6e085f
Update QueryParamPolicy.java
mrm9084 1c451cf
Fixing tags
mrm9084 cd062ee
Style fixes
mrm9084 edbecab
Update QueryParamPolicyTest.java
mrm9084 858ae3c
Update QueryParamPolicyTest.java
mrm9084 387731f
Update QueryParamPolicyTest.java
mrm9084 d73ca61
Update assets.json
mrm9084 0efdeb4
review items
mrm9084 e0d02bb
Merge branch 'main' into QueryParamaterPipeline
mrm9084 404b483
Update QueryParamPolicy.java
mrm9084 7193a4a
Merge branch 'QueryParamaterPipeline' of https://github.com/mrm9084/a…
mrm9084 3cbc14e
Update QueryParamPolicy.java
mrm9084 aa6a387
Update QueryParamPolicy.java
mrm9084 267caf3
Update QueryParamPolicy.java
mrm9084 e1907f1
Updating assets.json for azure-monitor-query
jairmyree dd05f82
updating test files to use TME subscription
jairmyree b1570ec
Updating assets.json for azure-monitor-query-metrics
jairmyree 5d43d7b
Changing monitor app-config dependency to current to pull new changes
jairmyree 3255ca4
Changing monitor app-config dependencies
jairmyree 110b832
updating assets.json
jairmyree 5595677
Merge branch 'main' into QueryParamaterPipeline
jairmyree 18dd52e
Changing monitor dependency to unreleased app config
jairmyree f1e8dd6
Merge branch 'main' into QueryParamaterPipeline
jairmyree 6a1e309
Updating assets.json files
jairmyree 6e20621
updated pom and assets.json
jairmyree 94139bc
Update QueryParamPolicyTest.java
mrm9084 e393d1f
Merge branch 'main' into QueryParamaterPipeline
mrm9084 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...ration/src/main/java/com/azure/data/appconfiguration/implementation/QueryParamPolicy.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| package com.azure.data.appconfiguration.implementation; | ||
|
|
||
| import java.util.Arrays; | ||
| import java.util.stream.Collectors; | ||
|
|
||
| import com.azure.core.http.HttpPipelineCallContext; | ||
| import com.azure.core.http.HttpRequest; | ||
| import com.azure.core.http.policy.HttpPipelineSyncPolicy; | ||
| import com.azure.core.util.logging.ClientLogger; | ||
|
|
||
| public final class QueryParamPolicy extends HttpPipelineSyncPolicy { | ||
| private static final ClientLogger LOGGER = new ClientLogger(QueryParamPolicy.class); | ||
|
|
||
mrm9084 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| @Override | ||
| protected void beforeSendingRequest(HttpPipelineCallContext context) { | ||
| HttpRequest request = context.getHttpRequest(); | ||
|
|
||
| try { | ||
| String url = request.getUrl().toString(); | ||
mrm9084 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| // Find the query string manually to preserve URL encoding | ||
| int queryIndex = url.indexOf('?'); | ||
mrm9084 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if (queryIndex != -1) { | ||
| String query = url.substring(queryIndex + 1); | ||
|
|
||
| if (!query.isEmpty()) { | ||
| String normalizedQuery | ||
| = Arrays.stream(query.split("&")).filter(pair -> !pair.isEmpty()).map(pair -> { | ||
mrm9084 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
mrm9084 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| int equalIndex = pair.indexOf('='); | ||
| return equalIndex != -1 | ||
| ? pair.substring(0, equalIndex).toLowerCase() + "=" + pair.substring(equalIndex + 1) | ||
| : pair.toLowerCase() + "="; | ||
mrm9084 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| }).sorted().collect(Collectors.joining("&")); | ||
| String urlWithoutQuery = url.substring(0, queryIndex); | ||
| String newUrl = urlWithoutQuery + "?" + normalizedQuery; | ||
mrm9084 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| request.setUrl(newUrl); | ||
| } | ||
| } | ||
| } catch (Exception e) { | ||
mrm9084 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // If URL parsing fails, continue without modification | ||
| LOGGER.warning( | ||
| "Failed to parse URL for query parameter normalization. " | ||
| + "Request will proceed with original URL. URL: {}, Error: {}", | ||
| request.getUrl(), e.getMessage(), e); | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.