top.jfunc.http.cookie.InMemoryCookieStore Maven / Gradle / Ivy
package top.jfunc.http.cookie;
import top.jfunc.http.request.HttpRequest;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author xiongshiyan at 2020/11/2 , contact me with email [email protected] or phone 15208384257
*/
public class InMemoryCookieStore implements CookieStore{
private Map cookieMap = new HashMap<>();
@Override
public List loadForRequest(HttpRequest httpRequest) throws IOException {
return new ArrayList<>(cookieMap.values());
}
@Override
public void saveFromResponse(List cookies, HttpRequest httpRequest) throws IOException {
for (Cookie cookie : cookies) {
cookieMap.put(cookie.getName(), cookie);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy