Class HeaderManager

All Implemented Interfaces:
Serializable, Cloneable, ConfigElement, Replaceable, Searchable, org.apache.jmeter.testelement.TestElement

public class HeaderManager extends ConfigTestElement implements Serializable, Replaceable
This class provides an interface to headers file to pass HTTP headers along with a request.
See Also:
  • Field Details

  • Constructor Details

    • HeaderManager

      public HeaderManager()
  • Method Details

    • getSchema

      public org.apache.jmeter.protocol.http.control.HeaderManagerSchema getSchema()
      Specified by:
      getSchema in interface org.apache.jmeter.testelement.TestElement
      Overrides:
      getSchema in class ConfigTestElement
    • getProps

      public org.apache.jmeter.testelement.schema.PropertiesAccessor<? extends HeaderManager,? extends org.apache.jmeter.protocol.http.control.HeaderManagerSchema> getProps()
      Specified by:
      getProps in interface org.apache.jmeter.testelement.TestElement
      Overrides:
      getProps in class ConfigTestElement
    • recoverRunningVersion

      public void recoverRunningVersion()
      Description copied from class: AbstractTestElement
      Specified by:
      recoverRunningVersion in interface org.apache.jmeter.testelement.TestElement
      Overrides:
      recoverRunningVersion in class AbstractTestElement
    • clear

      public void clear()
      Specified by:
      clear in interface org.apache.jmeter.testelement.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 String getColumnName(int column)
    • getColumnClass

      public Class<? extends String> getColumnClass(int column)
    • getHeader

      public Header getHeader(int row)
    • save

      public void save(String headFile) throws 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:
      IOException - if writing the headers fails
    • addFile

      public void addFile(String headerFile) throws 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:
      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
    • getFirstHeaderNamed

      public Header getFirstHeaderNamed(String name)
      Get the first header from Headers by the header name, or null if not found.
      Parameters:
      name - header name
      Returns:
      the first header from Headers by the header name, or null if not found
    • removeHeaderNamed

      public void removeHeaderNamed(String name)
      Remove from Headers the header named name
      Parameters:
      name - header name
    • merge

      @Deprecated public HeaderManager merge(org.apache.jmeter.testelement.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:
      IllegalArgumentException - if element is not an instance of HeaderManager
    • merge

      public HeaderManager merge(org.apache.jmeter.testelement.TestElement element)
      Merge the attributes with a another HeaderManager's attributes.
      Parameters:
      element - The object to be merged with
      Returns:
      merged HeaderManager
      Throws:
      IllegalArgumentException - if element is not an instance of HeaderManager
    • replace

      public int replace(String regex, String replaceBy, boolean caseSensitive) throws 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:
      Exception - when something fails while replacing