//capture request cookies
List<Cookie> cookies = (List<Cookie>) ctx.getAttribute("browsermob.http.request.cookies");
if (cookies != null) {
for (Cookie c : cookies) {
HarCookie hc = toHarCookie(c);
entry.getRequest().getCookies().add(hc);
}
}
String contentType = null;
if (response != null) {
try {
Header contentTypeHdr = response.getFirstHeader("Content-Type");
if (contentTypeHdr != null) {
contentType = contentTypeHdr.getValue();
NameValuePair nvp = contentTypeHdr.getElements()[0].getParameterByName("charset");
if (nvp != null) {
charSet = nvp.getValue();
}
}
if (os instanceof ByteArrayOutputStream) {
responseBody = ((ByteArrayOutputStream) os).toString(charSet);
if (verificationText != null) {
contentMatched = responseBody.contains(verificationText);
}
}
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
//capture response cookies
cookies = (List<Cookie>) ctx.getAttribute("browsermob.http.response.cookies");
if (cookies != null) {
for (Cookie c : cookies) {
HarCookie hc = toHarCookie(c);
entry.getResponse().getCookies().add(hc);
}
}
}