/** * Replaces all existing {@link LazyHeaderFactory LazyHeaderFactorys} for the given key * with the given {@link LazyHeaderFactory}. * * <p> If the given value is {@code null}, the header at the given key will be removed. </p> */ public Builder setHeader(@NonNull String key, @Nullable LazyHeaderFactory factory) { copyIfNecessary(); if (factory == null) { headers.remove(key); } else { List<LazyHeaderFactory> factories = getFactories(key); factories.clear(); factories.add(factory); } if (isUserAgentDefault && USER_AGENT_HEADER.equalsIgnoreCase(key)) { isUserAgentDefault = false; } return this; }
/** * Adds an {@link LazyHeaderFactory} that will be used to construct a value for the given * key lazily on a background thread. * * <p> Headers may have multiple values whose order is defined by the order in which * this method is called. </p> * * <p> This class does not prevent you from adding the same value to a given key multiple * times </p> */ public Builder addHeader(@NonNull String key, @NonNull LazyHeaderFactory factory) { if (isUserAgentDefault && USER_AGENT_HEADER.equalsIgnoreCase(key)) { return setHeader(key, factory); } copyIfNecessary(); getFactories(key).add(factory); return this; }
/** * Replaces all existing {@link LazyHeaderFactory LazyHeaderFactorys} for the given key * with the given {@link LazyHeaderFactory}. * * <p> If the given value is {@code null}, the header at the given key will be removed. </p> */ public Builder setHeader(String key, LazyHeaderFactory factory) { copyIfNecessary(); if (factory == null) { headers.remove(key); } else { List<LazyHeaderFactory> factories = getFactories(key); factories.clear(); factories.add(factory); } if (isEncodingDefault && ENCODING_HEADER.equalsIgnoreCase(key)) { isEncodingDefault = false; } if (isUserAgentDefault && USER_AGENT_HEADER.equalsIgnoreCase(key)) { isUserAgentDefault = false; } return this; }
/** * Replaces all existing {@link LazyHeaderFactory LazyHeaderFactorys} for the given key * with the given {@link LazyHeaderFactory}. * * <p> If the given value is {@code null}, the header at the given key will be removed. </p> */ public Builder setHeader(String key, LazyHeaderFactory factory) { copyIfNecessary(); if (factory == null) { headers.remove(key); } else { List<LazyHeaderFactory> factories = getFactories(key); factories.clear(); factories.add(factory); } if (isUserAgentDefault && USER_AGENT_HEADER.equalsIgnoreCase(key)) { isUserAgentDefault = false; } return this; }
/** * Adds an {@link LazyHeaderFactory} that will be used to construct a value for the given * key lazily on a background thread. * * <p> Headers may have multiple values whose order is defined by the order in which * this method is called. </p> * * <p> This class does not prevent you from adding the same value to a given key multiple * times </p> */ public Builder addHeader(String key, LazyHeaderFactory factory) { if (isUserAgentDefault && USER_AGENT_HEADER.equalsIgnoreCase(key)) { return setHeader(key, factory); } copyIfNecessary(); getFactories(key).add(factory); return this; }
/** * Adds an {@link LazyHeaderFactory} that will be used to construct a value for the given * key lazily on a background thread. * * <p> Headers may have multiple values whose order is defined by the order in which * this method is called. </p> * * <p> This class does not prevent you from adding the same value to a given key multiple * times </p> */ public Builder addHeader(String key, LazyHeaderFactory factory) { if ((isEncodingDefault && ENCODING_HEADER.equalsIgnoreCase(key)) || (isUserAgentDefault && USER_AGENT_HEADER.equalsIgnoreCase(key))) { return setHeader(key, factory); } copyIfNecessary(); getFactories(key).add(factory); return this; }