HTTPRequest { public String requestURI() { if (params.isEmpty()) return uri; var builder = new StringBuilder(256).append(uri).append(uri.indexOf('?') > -1 ? '&' : '?'); HTTPRequestHelper.urlEncoding(builder, params); return builder.toString(); } HTTPRequest(HTTPMethod method, String uri); void accept(ContentType contentType); void basicAuth(String user, String password); void bearerAuth(String token); void body(byte[] body, ContentType contentType); void body(String body, ContentType contentType); void form(Map<String, String> form); String requestURI(); final HTTPMethod method; final Map<String, String> params; final Map<String, String> headers; public String uri; public byte[] body; public ContentType contentType; public Map<String, String> form; public Duration connectTimeout; public Duration timeout; public Duration slowOperationThreshold; }
@Test void requestURI() { var request = new HTTPRequest(HTTPMethod.POST, "http: assertThat(request.requestURI()).isEqualTo("http: request.params.put("query", "value"); assertThat(request.requestURI()).isEqualTo("http: request = new HTTPRequest(HTTPMethod.POST, "http: request.params.put("q2", "v2"); assertThat(request.requestURI()).isEqualTo("http: }