Skip to content

[BUG] Azure-Core cannot encode with some character in query param #11451

@ChenTanyi

Description

@ChenTanyi

Describe the bug
Azure-Core cannot encode with some character in query param like $, /

To Reproduce
Steps to reproduce the behavior:
run the following code, it will request with http://httpbin.org/get?$filter=a/b

Code Snippet

public class App {
    public static void main(String[] args) {
        try {
            HttpClient client = new NettyAsyncHttpClientBuilder().build();
            Service proxy = RestProxy.create(Service.class, new HttpPipelineBuilder().policies(new UrlPolicy()).httpClient(client).build());

            proxy.get("http://httpbin.org/", "a/b")
                    .doOnNext(System.out::println)
                    .block();

        } catch (Exception e) {
            System.out.println(e.getMessage());
            e.printStackTrace();
        }
    }


    @Host("{$host}")
    @ServiceInterface(name = "Service")
    private interface Service {
        @Get("/get")
        Mono<Map<String, Object>> get(@HostParam("$host") String host, @QueryParam("$filter") String filter);
    }

    private static class UrlPolicy implements HttpPipelinePolicy {

        @Override
        public Mono<HttpResponse> process(HttpPipelineCallContext context, HttpPipelineNextPolicy next) {
            System.out.println(context.getHttpRequest().getUrl());
            return next.process();
        }
    }
}

Expected behavior
It should request with http://httpbin.org/get?%24filter=a%2Fb instead.

Setup (please complete the following information):

  • OS: Windows 10
  • IDE : Java 1.8.0_231
  • Version of the Library used
    • Azure-core, Azure-core-http-netty 1.5.0

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

  • Bug Description Added
  • Repro Steps Added
  • Setup information Added

Metadata

Metadata

Labels

Azure.Coreazure-coreClientThis issue points to a problem in the data-plane of the library.commoncommon module used by all azure SDKs (e.g. client, Mgmt)

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions