@Override public void addAll(MultiValueMap<String, String> values) { values.forEach(this::addAll); }
@Override public void addAll(MultiValueMap<String, String> values) { values.forEach(this::addAll); }
@Override public void addAll(MultiValueMap<String, String> values) { values.forEach(this.headers::add); }
@Override public void addAll(MultiValueMap<String, String> values) { values.forEach(this::addAll); }
/** * Add a map of request parameters to the {@link MockHttpServletRequest}, * for example when testing a form submission. * <p>If called more than once, new values get added to existing ones. * @param params the parameters to add * @since 4.2.4 */ public MockHttpServletRequestBuilder params(MultiValueMap<String, String> params) { params.forEach((name, values) -> { for (String value : values) { this.parameters.add(name, value); } }); return this; }
@SuppressWarnings("unchecked") private MultipartInserter withInternal(MultiValueMap<String, ?> values) { values.forEach((key, valueList) -> { for (Object value : valueList) { this.builder.part(key, value); } }); return this; }
public void addNativeHeaders(@Nullable MultiValueMap<String, String> headers) { if (headers == null) { return; } headers.forEach((key, values) -> values.forEach(value -> addNativeHeader(key, value))); }
/** * Provide request parameters identifying the request for this FlashMap. * @param params a Map with the names and values of expected parameters */ public FlashMap addTargetRequestParams(@Nullable MultiValueMap<String, String> params) { if (params != null) { params.forEach((key, values) -> { for (String value : values) { addTargetRequestParam(key, value); } }); } return this; }
private static <K, V> void copyMultiValueMap(MultiValueMap<K,V> source, MultiValueMap<K,V> target) { source.forEach((key, value) -> target.put(key, new LinkedList<>(value))); }
protected String serializeForm(MultiValueMap<String, Object> formData, Charset charset) { StringBuilder builder = new StringBuilder(); formData.forEach((name, values) -> values.forEach(value -> { try { if (builder.length() != 0) { builder.append('&'); } builder.append(URLEncoder.encode(name, charset.name())); if (value != null) { builder.append('='); builder.append(URLEncoder.encode(String.valueOf(value), charset.name())); } } catch (UnsupportedEncodingException ex) { throw new IllegalStateException(ex); } })); return builder.toString(); }
protected String serializeForm(MultiValueMap<String, String> formData, Charset charset) { StringBuilder builder = new StringBuilder(); formData.forEach((name, values) -> values.forEach(value -> { try { if (builder.length() != 0) { builder.append('&'); } builder.append(URLEncoder.encode(name, charset.name())); if (value != null) { builder.append('='); builder.append(URLEncoder.encode(value, charset.name())); } } catch (UnsupportedEncodingException ex) { throw new IllegalStateException(ex); } })); return builder.toString(); }
private MultiValueMap<String, String> encodeQueryParams(BiFunction<String, Type, String> encoder) { int size = this.queryParams.size(); MultiValueMap<String, String> result = new LinkedMultiValueMap<>(size); this.queryParams.forEach((key, values) -> { String name = encoder.apply(key, Type.QUERY_PARAM); List<String> encodedValues = new ArrayList<>(values.size()); for (String value : values) { encodedValues.add(value != null ? encoder.apply(value, Type.QUERY_PARAM) : null); } result.put(name, encodedValues); }); return CollectionUtils.unmodifiableMultiValueMap(result); }
/** * Return an unmodifiable view of the specified multi-value map. * @param map the map for which an unmodifiable view is to be returned. * @return an unmodifiable view of the specified multi-value map. * @since 3.1 */ @SuppressWarnings("unchecked") public static <K, V> MultiValueMap<K, V> unmodifiableMultiValueMap(MultiValueMap<? extends K, ? extends V> map) { Assert.notNull(map, "'map' must not be null"); Map<K, List<V>> result = new LinkedHashMap<>(map.size()); map.forEach((key, value) -> { List<? extends V> values = Collections.unmodifiableList(value); result.put(key, (List<V>) values); }); Map<K, List<V>> unmodifiableMap = Collections.unmodifiableMap(result); return toMultiValueMap(unmodifiableMap); }
@Override public void addAll(MultiValueMap<String, String> values) { values.forEach((key, list) -> this.headers.addAll(HttpString.tryFromString(key), list)); }
private void addRequestParams(MockHttpServletRequest request, MultiValueMap<String, String> map) { map.forEach((key, values) -> values.forEach(value -> { value = (value != null ? UriUtils.decode(value, StandardCharsets.UTF_8) : null); request.addParameter(UriUtils.decode(key, StandardCharsets.UTF_8), value); })); }
private MultiValueMap<String, String> expandQueryParams(UriTemplateVariables variables) { int size = this.queryParams.size(); MultiValueMap<String, String> result = new LinkedMultiValueMap<>(size); UriTemplateVariables queryVariables = new QueryUriTemplateVariables(variables); this.queryParams.forEach((key, values) -> { String name = expandUriComponent(key, queryVariables, this.variableEncoder); List<String> expandedValues = new ArrayList<>(values.size()); for (String value : values) { expandedValues.add(expandUriComponent(value, queryVariables, this.variableEncoder)); } result.put(name, expandedValues); }); return CollectionUtils.unmodifiableMultiValueMap(result); }
public AbstractHandlerMapping getHandlerMapping() { Map<String, Object> urlMap = new LinkedHashMap<>(); for (ServletWebSocketHandlerRegistration registration : this.registrations) { MultiValueMap<HttpRequestHandler, String> mappings = registration.getMappings(); mappings.forEach((httpHandler, patterns) -> { for (String pattern : patterns) { urlMap.put(pattern, httpHandler); } }); } WebSocketHandlerMapping hm = new WebSocketHandlerMapping(); hm.setUrlMap(urlMap); hm.setOrder(this.order); if (this.urlPathHelper != null) { hm.setUrlPathHelper(this.urlPathHelper); } return hm; }
/** * Return a handler mapping with the mapped ViewControllers. */ public AbstractHandlerMapping getHandlerMapping() { Map<String, Object> urlMap = new LinkedHashMap<>(); for (WebMvcStompWebSocketEndpointRegistration registration : this.registrations) { MultiValueMap<HttpRequestHandler, String> mappings = registration.getMappings(); mappings.forEach((httpHandler, patterns) -> { for (String pattern : patterns) { urlMap.put(pattern, httpHandler); } }); } WebSocketHandlerMapping hm = new WebSocketHandlerMapping(); hm.setUrlMap(urlMap); hm.setOrder(this.order); if (this.urlPathHelper != null) { hm.setUrlPathHelper(this.urlPathHelper); } return hm; }
private void params(MockHttpServletRequest request, UriComponents uriComponents) { uriComponents.getQueryParams().forEach((name, values) -> { String urlDecodedName = urlDecode(name); values.forEach(value -> { value = (value != null ? urlDecode(value) : ""); request.addParameter(urlDecodedName, value); }); }); for (NameValuePair param : this.webRequest.getRequestParameters()) { request.addParameter(param.getName(), param.getValue()); } }
/** * Check if any of the URI components contain any illegal characters. * @throws IllegalArgumentException if any component has illegal characters */ private void verify() { verifyUriComponent(getScheme(), Type.SCHEME); verifyUriComponent(this.userInfo, Type.USER_INFO); verifyUriComponent(this.host, getHostType()); this.path.verify(); this.queryParams.forEach((key, values) -> { verifyUriComponent(key, Type.QUERY_PARAM); for (String value : values) { verifyUriComponent(value, Type.QUERY_PARAM); } }); verifyUriComponent(getFragment(), Type.FRAGMENT); }