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

io.hyperfoil.core.http.CookieAppender Maven / Gradle / Ivy

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

import io.netty.handler.codec.http.HttpHeaderNames;
import io.hyperfoil.api.connection.HttpRequestWriter;
import io.hyperfoil.api.session.Session;
import io.hyperfoil.function.SerializableBiConsumer;
import io.vertx.core.logging.Logger;
import io.vertx.core.logging.LoggerFactory;

public class CookieAppender implements SerializableBiConsumer {
   private static final Logger log = LoggerFactory.getLogger(CookieAppender.class);

   @Override
   public void accept(Session session, HttpRequestWriter httpRequest) {
      CookieStore cookies = session.getResource(CookieStore.COOKIES);
      if (cookies == null) {
         log.error("No cookie store in the session. Did you add CookieRecorder?");
         return;
      }
      String cookie = cookies.getCookie(httpRequest.connection().host());
      if (cookie != null) {
         httpRequest.putHeader(HttpHeaderNames.COOKIE.toString(), cookie);
      }
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy