есть вот такой стринг в котрый я поместил header String header = httpURLConnection2.getHeaderFields().toString();
в нем находится что то подобное
{null=[HTTP/1.1 200 OK], Cache-Control=[no-store, no-cache, must-revalidate, post-check=0, pre-check=0], Connection=[keep-alive], Content-Type=[application/json], Date=[Mon, 10 Jul 2017 19:33:04 GMT], Expires=[Thu, 19 Nov 1981 08:52:00 GMT], Pragma=[no-cache], Server=[nginx/1.11.10], Set-Cookie=[PHPSESSID=tun3co90ia7dplj03nf573c4p3; path=/, usrnm=YnP%2BMucXYelNwLUYcAnycqUKqxrsLF%2F6UBHoGrV5gy81hFmwxdNVrEUgM0CIDpIEgl1FGwMzu9eEKgcsE65s8g%3D%3D; expires=Wed, 09-Aug-2017 19:33:04 GMT; Max-Age=2592000; path=/; domain=], Transfer-Encoding=[chunked], X-Android-Received-Millis=[1499715181888], X-Android-Response-Source=[NETWORK 200], X-Android-Selected-Protocol=[http/1.1], X-Android-Sent-Millis=[1499715181734], X-Powered-By=[PHP/5.5.9-1ubuntu4.21]}
как это можно распарсить либо как получить этот header подругому чтоб можно было распарсить вот сам код
try {
String email = params[1];
String password = params[2];
URL url = new URL(login_url);
URL url2 = new URL(login2);
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
HttpURLConnection httpURLConnection2 = (HttpURLConnection) url2.openConnection();
httpURLConnection.setDoOutput(true);
httpURLConnection.setDoInput(true);
httpURLConnection2.setDoOutput(true);
httpURLConnection2.setDoInput(true);
OutputStream outputStream = httpURLConnection.getOutputStream();
OutputStream outputStream2 = httpURLConnection2.getOutputStream();
BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream, "UTF-8"));
String post_data = URLEncoder.encode("username", "UTF-8") + "=" + URLEncoder.encode(email, "UTF-8") + "&"
+ URLEncoder.encode("password", "UTF-8") + "=" + URLEncoder.encode(password, "UTF-8") + "&"
+ URLEncoder.encode("gmc", "UTF-8") + "=" + URLEncoder.encode(id, "UTF-8");
BufferedWriter bufferedWriter2 = new BufferedWriter(new OutputStreamWriter(outputStream2, "UTF-8"));
String post_data2 = URLEncoder.encode("myusername", "UTF-8") + "=" + URLEncoder.encode(email, "UTF-8") + "&"
+ URLEncoder.encode("mypassword", "UTF-8") + "=" + URLEncoder.encode(password, "UTF-8")+ "&"
+ URLEncoder.encode("app_id", "UTF-8") + "=" + URLEncoder.encode("4f0n6tlqqkae4revct5bnk59g5", "UTF-8");
bufferedWriter.write(post_data);
bufferedWriter2.write(post_data2);
bufferedWriter.flush();
bufferedWriter.close();
bufferedWriter2.flush();
bufferedWriter2.close();
outputStream.close();
outputStream2.close();
InputStream inputStream = httpURLConnection.getInputStream();
InputStream inputStream2 = httpURLConnection2.getInputStream();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
BufferedReader bufferedReader2 = new BufferedReader(new InputStreamReader(inputStream2, "UTF-8"));
while ((line = bufferedReader2.readLine()) != null) {
cookies += line;
}
while ((line = bufferedReader.readLine()) != null) {
result += line;
}
header = httpURLConnection2.getHeaderFields().toString();
bufferedReader.close();
bufferedReader2.close();
inputStream.close();
inputStream2.close();
httpURLConnection.disconnect();
httpURLConnection2.disconnect();