2

I have a https request which its uri begins with capital letter. I have tested it in postman and i have gotten response; But in my code by vertx (io.vertx.core), I can not get desired response response. It seems that destination server reject me. It seems that my desired uri changes to lowercase automatically. Unfortunately the server does not accept the changed mode.

Desired uri : /Internalservice

https://example.com/Internalservice

I use this webClient: io.vertx.ext.web.client;

This is my method:

    public CompletionStage<HttpResponse> post(String host, int port, String uri, MultiMap headers, JsonObject body) {
        return client.post(port, host, uri)
                .putHeaders(headers)
                .timeout(requestTimeout.toMillis())
                .sendJsonObject(body)
                .toCompletionStage()
                .thenApply(response -> new HttpResponse(response.statusCode(), response.body() != null ?     response.body().getBytes() : new byte[]{}));
    }

what I have to do to handle this case sensitive uri?

  • What does "I can not get response" mean? Exactly what happens when you make the request? Does the same code work if you request e.g. `https://google.com`? How have you determined that the URL is being converted to lower case? – tgdavies Nov 30 '21 at 20:34
  • @tgdavies I have tested lower and uppercase, By uppercase I get response without any problem. yes, in form of https://google.com works for me. i can not get my desired response I mean. It detect me as an unknown user and reject my request. – Ali Hosseinzadeh Dec 01 '21 at 05:51

1 Answers1

2

I have found the answer! I have used of WebClient of io.vertx.ext.web.client to create a http post request. There is a method: HttpRequest postAbs(String absoluteURI) Which in its documentary we have:

 /**
   * Create an HTTP POST request to send to the server using an absolute URI, specifying a response handler to receive
   * the response
   * @param absoluteURI  the absolute URI
   * @return  an HTTP client request object
   */

so it helped me!

my method is:

public CompletionStage<HttpResponse> post(String uri, MultiMap headers, JsonObject body) {
    return client.postAbs(uri)
            .putHeaders(headers)
            .timeout(requestTimeout.toMillis())
            .sendJsonObject(body)
            .toCompletionStage()
            .thenApply(response -> new HttpResponse(response.statusCode(), response.body() != null ? response.body().getBytes() : new byte[]{}));
}

as you see the arguments are different from the previous version. Now I can enter https://example.com/Internalservice as the absolute uri. There will be no changes or conversion in desired uri.