package me.biezhi.weixin.util; import java.net.HttpURLConnection; import java.util.List; import java.util.Map; import blade.kit.http.HttpRequest; public class CookieUtil { public static String getCookie(HttpRequest request) { HttpURLConnection conn = request.getConnection(); Map<String, List<String>> resHeaders = conn.getHeaderFields(); StringBuffer sBuffer = new StringBuffer(); for (Map.Entry<String, List<String>> entry : resHeaders.entrySet()) { String name = entry.getKey(); if (name == null) continue; // http/1.1 line List<String> values = entry.getValue(); if (name.equalsIgnoreCase("Set-Cookie")) { for (String value : values) { if (value == null) { continue; } String cookie = value.substring(0, value.indexOf(";") + 1); sBuffer.append(cookie); } } } if(sBuffer.length() > 0){ return sBuffer.toString(); } return sBuffer.toString(); } }
最近下载更多
wuying8208 LV15
2023年7月27日
DarlingMeow LV5
2023年5月20日
bbczlitao LV9
2022年12月12日
18650066502 LV12
2022年11月28日
zhenghaokana LV2
2022年6月22日
dasen2022 LV6
2022年4月27日
lzlzyw LV14
2022年3月24日
机器人天天 LV1
2022年1月9日
三个焱枪手 LV1
2021年12月29日
疯子庭 LV8
2021年11月30日
最近浏览更多
locklock LV2
4月21日
Gin19960217 LV4
1月12日
yxzzxy LV3
2023年12月21日
dingyandy LV3
2023年11月6日
EFWAGGFAWGR
2023年10月19日
暂无贡献等级
412836806
2023年10月13日
暂无贡献等级
1441854423 LV2
2023年10月10日
zhaozhiwen123
2023年9月18日
暂无贡献等级
你好啊呐 LV19
2023年8月23日
最代码之星 LV16
2023年8月22日