@Override public FormInserter<String> with(MultiValueMap<String, String> values) { this.data.addAll(values); return this; }
@Override public void addAll(MultiValueMap<String, String> values) { this.headers.addAll(values); }
@Override public void addAll(String key, List<? extends String> values) { this.headers.addAll(key, values); }
/** * Add the given query parameters. * @param params the params * @return this UriComponentsBuilder * @since 4.0 */ @Override public UriComponentsBuilder queryParams(@Nullable MultiValueMap<String, String> params) { if (params != null) { this.queryParams.addAll(params); } return this; }
@Override public void addAll(String key, List<? extends String> values) { this.headers.addAll(key, values); }
@Override public void addAll(MultiValueMap<String, String> values) { this.headers.addAll(values); }
@Override public WebClient.Builder defaultCookie(String cookie, String... values) { initCookies().addAll(cookie, Arrays.asList(values)); return this; }
/** * Add the given query parameters. * @param params the params * @return this UriComponentsBuilder * @since 4.0 */ @Override public UriComponentsBuilder queryParams(@Nullable MultiValueMap<String, String> params) { if (params != null) { this.queryParams.addAll(params); } return this; }
public void addAliases(ConfigurationPropertyName name, ConfigurationPropertyName... aliases) { Assert.notNull(name, "Name must not be null"); Assert.notNull(aliases, "Aliases must not be null"); this.aliases.addAll(name, Arrays.asList(aliases)); }
private ClientRequest.Builder initRequestBuilder() { if (defaultRequest != null) { defaultRequest.accept(this); } return ClientRequest.create(this.httpMethod, initUri()) .headers(headers -> headers.addAll(initHeaders())) .cookies(cookies -> cookies.addAll(initCookies())) .attributes(attributes -> attributes.putAll(this.attributes)); }
parametersCollector = new LinkedMultiValueMap<>(); parametersCollector.addAll(parameters);
@Override public void process(AnnotationMetadata metadata, DeferredImportSelector selector) { for (String importClassName : selector.selectImports(metadata)) { this.instanceImports.add(new Entry(metadata, importClassName)); } TestImportGroup.imports.addAll(metadata, Arrays.asList(selector.selectImports(metadata))); }
public DefaultClientRequestBuilder(ClientRequest other) { Assert.notNull(other, "ClientRequest must not be null"); this.method = other.method(); this.url = other.url(); headers(headers -> headers.addAll(other.headers())); cookies(cookies -> cookies.addAll(other.cookies())); attributes(attributes -> attributes.putAll(other.attributes())); body(other.body()); }
public DefaultClientResponseBuilder(ClientResponse other) { Assert.notNull(other, "ClientResponse must not be null"); this.strategies = other.strategies(); statusCode(other.statusCode()); headers(headers -> headers.addAll(other.headers().asHttpHeaders())); cookies(cookies -> cookies.addAll(other.cookies())); }
public DefaultServerRequestBuilder(ServerRequest other) { Assert.notNull(other, "ServerRequest must not be null"); this.messageReaders = other.messageReaders(); this.exchange = other.exchange(); this.methodName = other.methodName(); this.uri = other.uri(); headers(headers -> headers.addAll(other.headers().asHttpHeaders())); cookies(cookies -> cookies.addAll(other.cookies())); attributes(attributes -> attributes.putAll(other.attributes())); }
@Test public void cookies() { MultiValueMap<String, ResponseCookie> newCookies = new LinkedMultiValueMap<>(); newCookies.add("name", ResponseCookie.from("name", "value").build()); Mono<EntityResponse<String>> result = EntityResponse.fromObject("foo").cookies(cookies -> cookies.addAll(newCookies)).build(); StepVerifier.create(result) .expectNextMatches(response -> newCookies.equals(response.cookies())) .expectComplete() .verify(); }
@Test public void cookies() { MultiValueMap<String, ResponseCookie> newCookies = new LinkedMultiValueMap<>(); newCookies.add("name", ResponseCookie.from("name", "value").build()); Mono<ServerResponse> result = ServerResponse.ok().cookies(cookies -> cookies.addAll(newCookies)).build(); StepVerifier.create(result) .expectNextMatches(response -> newCookies.equals(response.cookies())) .expectComplete() .verify(); }
@Test public void cookies() { MultiValueMap<String, ResponseCookie> newCookies = new LinkedMultiValueMap<>(); newCookies.add("name", ResponseCookie.from("name", "value").build()); Mono<RenderingResponse> result = RenderingResponse.create("foo").cookies(cookies -> cookies.addAll(newCookies)).build(); StepVerifier.create(result) .expectNextMatches(response -> newCookies.equals(response.cookies())) .expectComplete() .verify(); }
private ClientRequest withClientCookies(ClientRequest request) { return ClientRequest.from(request) .cookies( c -> { c.addAll(clientCookies()); }).build(); }
private Mono<ClientResponse> redirectIfNecessary(ClientRequest request, ExchangeFunction next, ClientResponse response) { URI location = response.headers().asHttpHeaders().getLocation(); String host = request.url().getHost(); String scheme = request.url().getScheme(); if (location != null) { String redirectUrl = location.toASCIIString(); if (location.getHost() == null) { redirectUrl = scheme+ "://" + host + location.toASCIIString(); } ClientRequest redirect = ClientRequest.method(HttpMethod.GET, URI.create(redirectUrl)) .headers(headers -> headers.addAll(request.headers())) .cookies(cookies -> cookies.addAll(request.cookies())) .attributes(attributes -> attributes.putAll(request.attributes())) .build(); return next.exchange(redirect).flatMap( r -> redirectIfNecessary(request, next, r)); } return Mono.just(response); } }