org.apache.jmeter.protocol.http.control

## Class HeaderManager

- java.lang.Object
- - org.apache.jmeter.testelement.AbstractTestElement
  - - org.apache.jmeter.config.ConfigTestElement
    - - org.apache.jmeter.protocol.http.control.HeaderManager

- All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, ConfigElement, Replaceable, Searchable, TestElement

      public class HeaderManager
      extends ConfigTestElement
      implements java.io.Serializable, Replaceable

  This class provides an interface to headers file to pass HTTP headers along with a request.
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `HEADERS`

    - ### Fields inherited from class org.apache.jmeter.config.ConfigTestElement

      `PASSWORD, USERNAME`

    - ### Fields inherited from interface org.apache.jmeter.testelement.TestElement

      `COMMENTS, ENABLED, GUI_CLASS, NAME, TEST_CLASS`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `HeaderManager()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `add()` Add an empty header.
    `void` | `add(Header h)` Add a header.
    `void` | `addFile(java.lang.String headerFile)` Add header data from a file.
    `void` | `clear()` Clear the TestElement of all data.
    `Header` | `get(int i)` Return the header at index i.
    `java.lang.Class<? extends java.lang.String>` | `getColumnClass(int column)`
    `int` | `getColumnCount()`
    `java.lang.String` | `getColumnName(int column)`
    `Header` | `getHeader(int row)`
    `CollectionProperty` | `getHeaders()` Get the collection of JMeterProperty entries representing the headers.
    `HeaderManager` | `merge(TestElement element)` Merge the attributes with a another HeaderManager's attributes.
    `HeaderManager` | `merge(TestElement element, boolean preferLocalValues)` Deprecated. since 3.2, use `merge(TestElement)` as this method will be removed in a future version
    `void` | `remove(int index)` Remove a header.
    `void` | `removeHeaderNamed(java.lang.String name)` Remove from Headers the header named name
    `int` | `replace(java.lang.String regex, java.lang.String replaceBy, boolean caseSensitive)` Replace in object by replaceBy
    `void` | `save(java.lang.String headFile)` Save the header data to a file.
    `int` | `size()` Return the number of headers.

    - ### Methods inherited from class org.apache.jmeter.config.ConfigTestElement

      `addConfigElement, addTestElement, expectsModification`

    - ### Methods inherited from class org.apache.jmeter.testelement.AbstractTestElement

      `addPropertiesValues, addProperty, addProperty, canRemove, clearTemporary, clearTestElementChildren, clone, emptyTemporary, equals, getComment, getName, getProperty, getPropertyAsBoolean, getPropertyAsBoolean, getPropertyAsDouble, getPropertyAsFloat, getPropertyAsInt, getPropertyAsInt, getPropertyAsLong, getPropertyAsLong, getPropertyAsString, getPropertyAsString, getSearchableTokens, getThreadContext, getThreadName, hashCode, isEnabled, isRunningVersion, isTemporary, logProperties, mergeIn, propertyIterator, recoverRunningVersion, removeProperty, setComment, setEnabled, setName, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setRunningVersion, setTemporary, setThreadContext, setThreadName, traverse, traverseCollection, traverseMap, traverseProperty`

    - ### Methods inherited from class java.lang.Object

      `finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.apache.jmeter.config.ConfigElement

      `clone`

    - ### Methods inherited from interface org.apache.jmeter.testelement.TestElement

      `removed`

- - ### Field Detail

    - #### HEADERS

          public static final java.lang.String HEADERS

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### HeaderManager

          public HeaderManager()

  - ### Method Detail

    - #### clear

          public void clear()

      Clear the TestElement of all data.
      Specified by:
        `clear` in interface `TestElement`
      Overrides:
        `clear` in class `AbstractTestElement`

    - #### getHeaders

          public CollectionProperty getHeaders()

      Get the collection of JMeterProperty entries representing the headers.
      Returns:
        the header collection property

    - #### getColumnCount

          public int getColumnCount()

    - #### getColumnName

          public java.lang.String getColumnName(int column)

    - #### getColumnClass

          public java.lang.Class<? extends java.lang.String> getColumnClass(int column)

    - #### getHeader

          public Header getHeader(int row)

    - #### save

          public void save(java.lang.String headFile)
                    throws java.io.IOException

      Save the header data to a file.
      Parameters:
        `headFile` - name of the file to store headers into. If name is relative the system property `user.dir` will be prepended
      Throws:
        `java.io.IOException` - if writing the headers fails

    - #### addFile

          public void addFile(java.lang.String headerFile)
                       throws java.io.IOException

      Add header data from a file.
      Parameters:
        `headerFile` - name of the file to read headers from. If name is relative the system property `user.dir` will be prepended
      Throws:
        `java.io.IOException` - if reading headers fails

    - #### add

          public void add(Header h)

      Add a header.
      Parameters:
        `h` - `Header` to add

    - #### add

          public void add()

      Add an empty header.

    - #### remove

          public void remove(int index)

      Remove a header.
      Parameters:
        `index` - index from the header to remove

    - #### size

          public int size()

      Return the number of headers.
      Returns:
        number of headers

    - #### get

          public Header get(int i)

      Return the header at index i.
      Parameters:
        `i` - index of the header to get
      Returns:
        `Header` at index `i`

    - #### removeHeaderNamed

          public void removeHeaderNamed(java.lang.String name)

      Remove from Headers the header named name
      Parameters:
        `name` - header name

    - #### merge

          @Deprecated
          public HeaderManager merge(TestElement element,
                                                 boolean preferLocalValues)

      Deprecated. since 3.2, use `merge(TestElement)` as this method will be removed in a future version
      Merge the attributes with a another HeaderManager's attributes.
      Parameters:
        `element` - The object to be merged with
        `preferLocalValues` - Not used
      Returns:
        merged HeaderManager
      Throws:
        `java.lang.IllegalArgumentException` - if `element` is not an instance of `HeaderManager`

    - #### merge

          public HeaderManager merge(TestElement element)

      Merge the attributes with a another HeaderManager's attributes.
      Parameters:
        `element` - The object to be merged with
      Returns:
        merged HeaderManager
      Throws:
        `java.lang.IllegalArgumentException` - if `element` is not an instance of `HeaderManager`

    - #### replace

          public int replace(java.lang.String regex,
                             java.lang.String replaceBy,
                             boolean caseSensitive)
                      throws java.lang.Exception

      Description copied from interface: `Replaceable`
      Replace in object by replaceBy
      Specified by:
        `replace` in interface `Replaceable`
      Parameters:
        `regex` - Regular expression to search for
        `replaceBy` - Text used as replacement
        `caseSensitive` - flag, whether search should be done case sensitive
      Returns:
        number of replacements
      Throws:
        `java.lang.Exception` - when something fails while replacing

Copyright © 1998-2018 Apache Software Foundation. All Rights Reserved.