Sets headers for this resource request. Overrides all headers previously added.

@param headerMap A multimap containing the header names and corresponding values
194090
public void setHeaders(Map<String, List<String>> headerMap) {
        headers = new Headers.Builder();

        for (Map.Entry<String, List<String>> e : headerMap.entrySet()) {
            for (String headerValue : e.getValue()) {
                addHeader(e.getKey(), headerValue);
            }
        }
    }
1320279
public RequestTemplate headers(Map<String, Collection<String>> headers) {
    if (headers != null && !headers.isEmpty()) {
      headers.forEach(this::header);
    } else {
      this.headers.clear();
    }
    return this;
  }
665577
@Override
	public void set(String headerName, String headerValue) {
		List<String> headerValues = new LinkedList<String>();
		headerValues.add(headerValue);
		headers.put(headerName, headerValues);
	}
1257222
private void setHeaderList(Map<String, List<String>> headers, String name, String value) {

        List<String> values = new ArrayList<String>();
        values.add(SET_HEADER + value);
        headers.put(name, values);
    }
243763
public static void processHeaders(Map<String, List<String>> headers, HttpServletResponse res) {

        if (headers != null) {
            Iterator<Map.Entry<String, List<String>>> i = headers.entrySet().iterator();
            while (i.hasNext()) {
                Map.Entry<String, List<String>> entry = i.next();
                String key = entry.getKey();
                List<String> l = entry.getValue();
                for (int j = 0; j < l.size(); j++) {
                    if ((j == 0) && ((l.get(0)).startsWith(SET_HEADER))) {
                        String s = l.get(0);
                        res.setHeader(key, s.substring(SET_HEADER.length()));
                    } else {
                        res.addHeader(key, l.get(j));
                    }
                }
            }
        }
    }
671015
@Nonnull
  public FineUploaderBasic setCustomHeaders (@Nullable final Map <String, String> aCustomHeaders)
  {
    m_aRequestCustomHeaders.setAll (aCustomHeaders);
    return this;
  }
1018090
@Override
  public void header(String key, String value)
  {
    _is.header(key, value);
  }
1066598
public void setAllHeaders (@Nonnull final HttpHeaderMap aOther)
  {
    ValueEnforcer.notNull (aOther, "Other");
    // Don't use putAll for case sensitivity
    for (final Map.Entry <String, ICommonsList <String>> aEntry : aOther.m_aHeaders.entrySet ())
    {
      final String sKey = aEntry.getKey ();
      removeHeaders (sKey);
      for (final String sValue : aEntry.getValue ())
        addHeader (sKey, sValue);
    }
  }

  /**
   * Add all headers from the passed map. Existing headers with the same name are
   * extended.
   *
   * @param aOther
   *        The header map to add. May not be <code>null</code>.
   */
  public void addAllHeaders (@Nonnull final HttpHeaderMap aOther)
  {
    ValueEnforcer.notNull (aOther, "Other");
    for (final Map.Entry <String, ICommonsList <String>> aEntry : aOther.m_aHeaders.entrySet ())
    {
      final String sKey = aEntry.getKey ();
      for (final String sValue : aEntry.getValue ())
        addHeader (sKey, sValue);
    }
  }

  @Nonnull
  @ReturnsMutableCopy
  public ICommonsOrderedMap <String, ICommonsList <String>> getAllHeaders ()
  {
    return m_aHeaders.getClone ();
  }

  /**
   * @return A copy of all contained header names. Never <code>null</code>.
   */
  @Nonnull
  @ReturnsMutableCopy
  public ICommonsOrderedSet <String> getAllHeaderNames ()
  {
    return m_aHeaders.copyOfKeySet ();
  }

  /**
   * Get all header values of a certain header name
   *
   * @param sName
   *        The name to be searched.
   * @return The list with all matching values. Never <code>null</code> but maybe
   *         empty.
   */
  @Nonnull
  @ReturnsMutableCopy
  public ICommonsList <String> getAllHeaderValues (@Nullable final String sName)
  {
    if (StringHelper.hasText (sName))
    {
      final ICommonsList <String> aValues = _getHeaderList (sName);
      if (aValues != null)
        return aValues.getClone ();
    }
    return new CommonsArrayList <> ();
  }

  /**
   * Get the first header value of a certain header name
   *
   * @param sName
   *        The name to be searched.
   * @return The first matching value or <code>null</code>.
   */
  @Nullable
  public String getFirstHeaderValue (@Nullable final String sName)
  {
    if (StringHelper.hasText (sName))
    {
      final ICommonsList <String> aValues = _getHeaderList (sName);
      if (aValues != null)
        return aValues.getFirst ();
    }
    return null;
  }

  /**
   * Get the header value as a combination of all contained values
   *
   * @param sName
   *        The header name to retrieve. May be <code>null</code>.
   * @param sDelimiter
   *        The delimiter to be used. May not be <code>null</code>.
   * @return <code>null</code> if no such header is contained.
   */
  @Nullable
  public String getHeaderCombined (@Nullable final String sName, @Nonnull final String sDelimiter)
  {
    if (StringHelper.hasText (sName))
    {
      final ICommonsList <String> aValues = _getHeaderList (sName);
      if (aValues != null)
        return StringHelper.getImploded (sDelimiter, aValues);
    }
    return null;
  }

  public boolean containsHeaders (@Nullable final String sName)
  {
    if (StringHelper.hasNoText (sName))
      return false;
    return _getHeaderList (sName) != null;
  }

  /**
   * Remove all header values where the name matches the provided filter.
   *
   * @param aNameFilter
   *        The name filter to be applied. May not be <code>null</code>.
   * @return {@link EChange}
   */
  @Nonnull
  public EChange removeHeadersIf (@Nonnull final Predicate <? super String> aNameFilter)
  {
    return m_aHeaders.removeIfKey (aNameFilter);
  }

  /**
   * Remove all header values with the provided name
   *
   * @param sName
   *        The name to be removed. May be <code>null</code>.
   * @return {@link EChange}
   */
  @Nonnull
  public EChange removeHeaders (@Nullable final String sName)
  {
    if (StringHelper.hasNoText (sName))
      return EChange.UNCHANGED;

    final Map.Entry <String, ICommonsList <String>> aEntry = _getHeaderEntry (sName);
    if (aEntry != null)
      return m_aHeaders.removeObject (aEntry.getKey ());

    return EChange.UNCHANGED;
  }

  @Nonnull
  public EChange removeHeader (@Nullable final String sName, @Nullable final String sValue)
  {
    final Map.Entry <String, ICommonsList <String>> aEntry = _getHeaderEntry (sName);
    final boolean bRemoved = aEntry != null && aEntry.getValue ().remove (sValue);
    if (bRemoved && aEntry.getValue ().isEmpty ())
    {
      // If the last value was removed, remove the whole header
      m_aHeaders.remove (aEntry.getKey ());
    }

    return EChange.valueOf (bRemoved);
  }

  @Nonnull
  public Iterator <Map.Entry <String, ICommonsList <String>>> iterator ()
  {
    return m_aHeaders.entrySet ().iterator ();
  }

  @Nonnegative
  public int size ()
  {
    return m_aHeaders.size ();
  }

  public boolean isEmpty ()
  {
    return m_aHeaders.isEmpty ();
  }

  /**
   * Invoke the provided consumer for every name/value pair. The value is
   * automatically unified since v9.3.1.
   *
   * @param aConsumer
   *        Consumer with key and unified value to be invoked. May not be
   *        <code>null</code>.
   * @see #getUnifiedValue(String)
   */
  public void forEachSingleHeader (@Nonnull final BiConsumer <? super String, ? super String> aConsumer)
  {
    for (final Map.Entry <String, ICommonsList <String>> aEntry : m_aHeaders.entrySet ())
    {
      final String sKey = aEntry.getKey ();
      for (final String sValue : aEntry.getValue ())
      {
        final String sUnifiedValue = getUnifiedValue (sValue);
        aConsumer.accept (sKey, sUnifiedValue);
      }
    }
  }

  /**
   * Invoke the provided consumer for every header line. The value is
   * automatically unified since v9.3.1.
   *
   * @param aConsumer
   *        Consumer with the assembled line to be invoked. May not be
   *        <code>null</code>.
   * @see #getUnifiedValue(String)
   */
  public void forEachHeaderLine (@Nonnull final Consumer <? super String> aConsumer)
  {
    for (final Map.Entry <String, ICommonsList <String>> aEntry : m_aHeaders.entrySet ())
    {
      final String sKey = aEntry.getKey ();
      for (final String sValue : aEntry.getValue ())
      {
        final String sHeaderLine = sKey + ": " + getUnifiedValue (sValue);
        aConsumer.accept (sHeaderLine);
      }
    }
  }

  @Nonnull
  @ReturnsMutableCopy
  public ICommonsList <String> getAllHeaderLines ()
  {
    final ICommonsList <String> ret = new CommonsArrayList <> ();
    forEachHeaderLine (ret::add);
    return ret;
  }

  public void setContentLength (final long nLength)
  {
    _setHeader (CHttpHeader.CONTENT_LENGTH, Long.toString (nLength));
  }

  public void setContentType (@Nonnull final String sContentType)
  {
    _setHeader (CHttpHeader.CONTENT_TYPE, sContentType);
  }

  @Nonnull
  @ReturnsMutableCopy
  public HttpHeaderMap getClone ()
  {
    return new HttpHeaderMap (this);
  }

  @Override
  public boolean equals (final Object o)
  {
    if (o == this)
      return true;
    if (o == null || !getClass ().equals (o.getClass ()))
      return false;
    final HttpHeaderMap rhs = (HttpHeaderMap) o;
    return m_aHeaders.equals (rhs.m_aHeaders);
  }

  @Override
  public int hashCode ()
  {
    return new HashCodeGenerator (this).append (m_aHeaders).getHashCode ();
  }

  @Override
  public String toString ()
  {
    return new ToStringGenerator (this).append ("Headers", m_aHeaders).getToString ();
  }
}
21484
public void setHeader(HeaderFooter header) {
        this.header = header;
        DocListener listener;
		for (Iterator iterator = listeners.iterator(); iterator.hasNext();) {
            listener = (DocListener) iterator.next();
            listener.setHeader(header);
        }
    }
821695
public void addHeader(String key, Object value) {
		List<Object> values = headers.get(key);
		if (values == null) {
			headers.put(key, values = new ArrayList<Object>());
		}
		values.add(value);
	}
335191
public void addHeader(String key, String value) {
        if (key.equals("As-User")) {
            for (int i = 0; i < this.headers.size(); i++) {
                if (this.headers.get(i).getKey().equals("As-User")) {
                    this.headers.remove(i);
                }
            }
        }
        if (key.equals("X-Box-UA")) {
            throw new IllegalArgumentException("Altering the X-Box-UA header is not permitted");
        }
        this.headers.add(new RequestHeader(key, value));
    }
1274831
@SuppressWarnings("unchecked")
    public void setHeaders(final Map<String, Object> headers) {
        this.headers.clear();
        for (Map.Entry<String, Object> entry: headers.entrySet()) {
            if (entry.getValue() instanceof List) {
                List value = (List) entry.getValue();
                // verify they are all strings
                for (Object o: value) {
                    Assert.isTrue(o instanceof String, o + " is not a string it is a: '" +
                            o.getClass() + "'");
                }
                this.headers.put(entry.getKey(), (List<String>) entry.getValue());
            } else if (entry.getValue() instanceof String) {
                final List<String> value = Collections.singletonList((String) entry.getValue());
                this.headers.put(entry.getKey(), value);
            } else {
                throw new IllegalArgumentException("Only strings and list of strings may be headers");
            }
        }
    }
1291458
public T addHeaders(Map<String, String> headers) {
		if(CollectionUtil.isEmpty(headers)) {
			return (T)this;
		}
		
		for (Entry<String,String> entry : headers.entrySet()) {
			this.header(entry.getKey(), StrUtil.nullToEmpty(entry.getValue()), false);
		}
		return (T)this;
	}
1335473
public void set(String name, String value)
    {
        HeaderName hn = getHeaderName(name);
        set(hn, value);
    }
263014
@InterfaceAudience.Public
    public void setHeaders(Map<String, Object> requestHeadersParam) {
        if (requestHeadersParam != null && !requestHeaders.equals(requestHeadersParam)) {
            requestHeaders = requestHeadersParam;
        }
    }
586377
public Response andHeaders(Map<HttpString, String> headers) {
        Objects.requireNonNull(headers, Required.HEADERS.toString());
        this.headers.putAll(headers);

        return this;
    }
765369
public CustomHeadersInterceptor addHeaderMultimap(Map<String, List<String>> headers) {
        this.headers.putAll(headers);
        return this;
    }