All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.hyperfoil.http.handlers.CountHeadersHandler Maven / Gradle / Ivy

There is a newer version: 0.27.1
Show newest version
package io.hyperfoil.http.handlers;

import org.kohsuke.MetaInfServices;

import io.hyperfoil.api.config.Name;
import io.hyperfoil.http.api.HttpRequest;
import io.hyperfoil.http.api.HeaderHandler;
import io.hyperfoil.api.statistics.IntValue;

public class CountHeadersHandler implements HeaderHandler {
   @Override
   public void handleHeader(HttpRequest request, CharSequence header, CharSequence value) {
      IntValue custom = request.statistics().getCustom(request.startTimestampMillis(), header, IntValue::new);
      custom.add(1);
   }

   /**
    * Stores number of occurences of each header in custom statistics (these can be displayed in CLI using the stats -c command).
    */
   @MetaInfServices(HeaderHandler.Builder.class)
   @Name("countHeaders")
   public static class Builder implements HeaderHandler.Builder {
      @Override
      public CountHeadersHandler build() {
         return new CountHeadersHandler();
      }
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy