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

com.emily.infrastructure.autoconfigure.httpclient.factory.HttpContextFactory Maven / Gradle / Ivy

There is a newer version: 5.0.2
Show newest version
/*
package com.emily.infrastructure.autoconfigure.httpclient.factory;

import com.emily.infrastructure.autoconfigure.httpclient.context.HttpContextHolder;
import org.apache.hc.client5.http.config.RequestConfig;
import org.apache.hc.client5.http.protocol.HttpClientContext;
import org.apache.hc.core5.http.protocol.HttpContext;
import org.springframework.http.HttpMethod;

import java.net.URI;
import java.util.Objects;
import java.util.function.BiFunction;

*/
/**
 * 自定义HttpContext HTTP进程执行状态,它是一种可用于将属性名称映射到属性值的结构
 *
 * @author Emily
 * @since 4.1.3
 *//*

public class HttpContextFactory implements BiFunction {
    @Override
    public HttpContext apply(HttpMethod httpMethod, URI uri) {
        RequestConfig requestConfig = HttpContextHolder.current();
        if (Objects.nonNull(requestConfig)) {
            HttpContext context = HttpClientContext.create();
            context.setAttribute(HttpClientContext.REQUEST_CONFIG, requestConfig);
            return context;
        }
        return null;
    }
}
*/




© 2015 - 2025 Weber Informatics LLC | Privacy Policy