/** * Replaces the values for the given key with the given values. * * @param key The key * @param values The new values * @return This object */ public FluentCaseInsensitiveStringsMap replace(final String key, final String... values) { return replace(key, Arrays.asList(values)); }
public T setHeader(String name, String value) { request.headers.replace(name, value); return derived.cast(this); }
/** * Replace the values for all keys from the given map that are also present in this object, with the values from the given map. * All key-values from the given object that are not present in this object, will be added to it. * * @param src The source object * @return This object */ public FluentCaseInsensitiveStringsMap replaceAll(FluentCaseInsensitiveStringsMap src) { if (src != null) { for (Map.Entry<String, List<String>> header : src) { replace(header.getKey(), header.getValue()); } } return this; }
/** * Replace the values for all keys from the given map that are also present in this object, with the values from the given map. * All key-values from the given object that are not present in this object, will be added to it. * * @param src The source map * @return This object */ public FluentCaseInsensitiveStringsMap replaceAll(Map<? extends String, ? extends Collection<String>> src) { if (src != null) { for (Map.Entry<? extends String, ? extends Collection<String>> header : src.entrySet()) { replace(header.getKey(), header.getValue()); } } return this; }
/** * Set an HTTP header. */ @Override public WSRequest setHeader(String name, String value) { headers.replace(name, value); return super.setHeader(name, value); }
@Override public List<String> put(String key, List<String> value) { if (key == null) { throw new NullPointerException("Null keys are not allowed"); } List<String> oldValue = get(key); replace(key, value); return oldValue; }
private Promise<Response> executeString(String method, String body) { FluentCaseInsensitiveStringsMap headers = new FluentCaseInsensitiveStringsMap(this.headers); // Detect and maybe add charset String contentType = headers.getFirstValue(HttpHeaders.Names.CONTENT_TYPE); if (contentType == null) { contentType = "text/plain"; } String charset = AsyncHttpProviderUtils.parseCharset(contentType); if (charset == null) { charset = "utf-8"; headers.replace(HttpHeaders.Names.CONTENT_TYPE, contentType + "; charset=utf-8"); } WSRequest req = new WSRequest(method).setBody(body) .setUrl(url) .setHeaders(headers) .setQueryParameters(new FluentStringsMap(queryParameters)) .setBodyEncoding(charset); return execute(req); }