跨服务器登录验证(单点登录SSO)的过程和Java实现(5)
发布时间:2021-06-05
发布时间:2021-06-05
sb.append("Accept-Charset: GB2312,utf-8;q=0.7,*;q=0.7\r\n"); sb.append("Referer: /3rdServices/50hero\r\n");
sb.append("\r\n\r\n");
OutputStream os = socket.getOutputStream();
os.write(sb.toString().getBytes("UTF-8"));
os.flush();
InputStream is = socket.getInputStream();
BufferedReader reader = new BufferedReader(new
InputStreamReader(is, "UTF-8")); // 读取结果
String line;
StringBuilder cookieSb = new StringBuilder();
int index;
while ((line = reader.readLine()) != null) {
if (line.length() == 0) {
break;
}
if (line.startsWith("Set-Cookie:")) {
index = line.indexOf(";");
if (index > 12) {
cookieSb.append(line.substring(12, index + 1)); }
}
}
is.close();
reader.close();
return cookieSb.toString();
} finally {
socket.close();
}
}
}
上一篇:小学英语教材教法测试题(五)
下一篇:后勤保障工作措施