azure-sdk-for-java icon indicating copy to clipboard operation
azure-sdk-for-java copied to clipboard

[FEATURE REQ] Encode invalid URL character, even when encoded=true on PathParam or QueryParam

Open weidongxu-microsoft opened this issue 6 months ago • 3 comments

Is your feature request related to a problem? Please describe.

@PathParam(value = "<>", encoded = true) or @QueryParam(value = "<>", encoded = true).

If customer sends some value that containsinvalid character (e.g. "foo bar" which contains a space), the URL sent would include the space, e.g.

"HTTP request","method":"GET","url":"https://localhost:3000/contoso/v1/contoso/foo bar"

(I tested on Netty and OkHttp client)

This would be an invalid URL.

Describe the solution you'd like azure-core keeps the reserve character like / or %, but still percent-encoding the character that would be invalid in URL.

We need some investigation about what character is invalid in URL.

Some discussion here https://github.com/Azure/cadl-ranch/pull/673#discussion_r1715262451

Reply from Python, the percent-encoding happens in their underlying http client.

Describe alternatives you've considered Codegen may do the escaping. But it would be more consistent if in azure-core

Additional context Add any other context or screenshots about the feature request here.

Information Checklist Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

  • [x] Description Added
  • [x] Expected solution specified

weidongxu-microsoft avatar Aug 13 '24 09:08 weidongxu-microsoft