Skip to content

Commit

Permalink
Fix URL query escape for RegionStatsByStartEndKey
Browse files Browse the repository at this point in the history
Signed-off-by: JmPotato <[email protected]>
  • Loading branch information
JmPotato committed Nov 15, 2023
1 parent 272d561 commit 5d35dec
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions client/http/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ func RegionByKey(key []byte) string {
// RegionsByKey returns the path of PD HTTP API to scan regions with given start key, end key and limit parameters.
func RegionsByKey(startKey, endKey []byte, limit int) string {
return fmt.Sprintf("%s?start_key=%s&end_key=%s&limit=%d",
regionsByKey, url.QueryEscape(string(startKey)), url.QueryEscape(string(endKey)), limit)
regionsByKey,
url.QueryEscape(string(startKey)),
url.QueryEscape(string(endKey)),
limit)

Check warning on line 85 in client/http/api.go

View check run for this annotation

Codecov / codecov/patch

client/http/api.go#L82-L85

Added lines #L82 - L85 were not covered by tests
}

// RegionsByStoreID returns the path of PD HTTP API to get regions by store ID.
Expand All @@ -88,8 +91,11 @@ func RegionsByStoreID(storeID uint64) string {
}

// RegionStatsByStartEndKey returns the path of PD HTTP API to get region stats by start key and end key.
func RegionStatsByStartEndKey(startKey, endKey string) string {
return fmt.Sprintf("%s?start_key=%s&end_key=%s", StatsRegion, startKey, endKey)
func RegionStatsByStartEndKey(startKey, endKey []byte) string {
return fmt.Sprintf("%s?start_key=%s&end_key=%s",
StatsRegion,
url.QueryEscape(string(startKey)),
url.QueryEscape(string(endKey)))

Check warning on line 98 in client/http/api.go

View check run for this annotation

Codecov / codecov/patch

client/http/api.go#L95-L98

Added lines #L95 - L98 were not covered by tests
}

// StoreByID returns the store API with store ID parameter.
Expand Down
2 changes: 1 addition & 1 deletion client/http/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ func (c *client) GetRegionStatusByKey(ctx context.Context, startKey, endKey []by
var regionStats RegionStats
err := c.requestWithRetry(
ctx, "GetRegionStatusByKey",
RegionStatsByStartEndKey(string(startKey), string(endKey)), http.MethodGet,
RegionStatsByStartEndKey(startKey, endKey), http.MethodGet,
&regionStats,
)
if err != nil {
Expand Down

0 comments on commit 5d35dec

Please sign in to comment.