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

io.github.danielliu1123.httpexchange.HttpExchangeMetadata Maven / Gradle / Ivy

There is a newer version: 3.4.0-RC1
Show newest version
package io.github.danielliu1123.httpexchange;

import jakarta.annotation.Nullable;
import java.util.LinkedHashMap;
import java.util.List;
import lombok.Data;

/**
 * {@link HttpExchangeMetadata} is used to store request metadata, such as timeout, headers, etc.
 *
 * 

Those values will be set to request at runtime. * * @author Freeman * @see HttpExchangeClientHttpRequestInterceptor * @see RequestConfiguratorBeanPostProcessor * @since 3.2.1 */ @Data public class HttpExchangeMetadata { private static final ThreadLocal HOLDER = new InheritableThreadLocal<>(); /** * Read timeout in milliseconds. */ private Integer readTimeout; /** * Request headers to be added. */ private LinkedHashMap> headers = new LinkedHashMap<>(); @Nullable public static HttpExchangeMetadata get() { return HOLDER.get(); } public static void set(HttpExchangeMetadata metadata) { HOLDER.set(metadata); } public static void remove() { HOLDER.remove(); } HttpExchangeMetadata copy() { HttpExchangeMetadata metadata = new HttpExchangeMetadata(); metadata.setReadTimeout(getReadTimeout()); metadata.setHeaders(new LinkedHashMap<>(getHeaders())); return metadata; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy