public SagaResponse with()

in transports/transport-httpclient/src/main/java/org/apache/servicecomb/saga/transports/httpclient/HttpClientTransport.java [66:98]


  public SagaResponse with(String address, String path, String method, Map<String, Map<String, String>> params) {
    URIBuilder builder = new URIBuilder().setScheme("http").setHost(address).setPath(path);

    if (params.containsKey("query")) {
      for (Entry<String, String> entry : params.get("query").entrySet()) {
        builder.addParameter(entry.getKey(), entry.getValue());
      }
    }

    try {
      URI uri = builder.build();
      Request request = requestFactories.getOrDefault(
          method.toUpperCase(),
          exceptionThrowingFunction(method)).apply(uri);

      request.socketTimeout(requestTimeout);
      if (params.containsKey("json")) {
        request.bodyString(params.get("json").get("body"), ContentType.APPLICATION_JSON);
      }

      if (params.containsKey("form")) {
        Form form = Form.form();
        for (Entry<String, String> entry : params.get("form").entrySet()) {
          form.add(entry.getKey(), entry.getValue()).build();
        }
        request.bodyForm(form.build());
      }

      return this.on(request);
    } catch (URISyntaxException e) {
      throw new TransportFailedException("Wrong request URI", e);
    }
  }