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

restx.specs.WhenCookieHeaderLoader Maven / Gradle / Ivy

There is a newer version: 1.2.0-rc2
Show newest version
package restx.specs;

import com.google.common.base.Splitter;
import restx.factory.Component;

/**
 * @author fcamblor
 */
@Component
public class WhenCookieHeaderLoader implements RestxSpecLoader.WhenHeaderLoader {
    @Override
    public String detectionPattern() {
        return "Cookie:";
    }

    @Override
    public void loadHeader(String headerValue, WhenHttpRequest.Builder whenHttpRequestBuilder) {
        for (String s : Splitter.on(";").trimResults().split(headerValue)) {
            int i = s.indexOf('=');

            String name = s.substring(0, i);
            String value = s.substring(i + 1);
            whenHttpRequestBuilder.addCookie(name, value);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy