Examples of HarCookie


Examples of org.browsermob.core.har.HarCookie

  public List<HarCookie> getCookies(HttpResponse response) {
    List<HarCookie> cookies = Lists.newLinkedList();
        for(Header hdr : response.getHeaders("Set-Cookie")) {                                  
          Map<String, String> cookieData = parseSetCookieHeader(hdr);
         
          HarCookie cookie = new HarCookie();
          cookie.setName(cookieData.get("name"));
          cookie.setValue(cookieData.get("value"));         
          cookie.setPath(cookieData.get("path"));
          cookie.setDomain(cookieData.get("domain"));         
         
          String expires = cookieData.get("expires");
          if (expires != null) {
              Date date = parseDate(expires);                           
              cookie.setExpires(date);   
          }
          cookies.add(cookie);
        }
        return cookies;
  }
View Full Code Here

Examples of org.browsermob.core.har.HarCookie

    List<HarCookie> cookies = newLinkedList();
    for(Header hdr : request.getHeaders("Cookie")) {
      String[] pairs = hdr.getValue().split("; ")
      for (String p : pairs) {
        HarNameValuePair pair = nameValuePair(p);
        HarCookie cookie = new HarCookie();
        cookie.setName(pair.getName());
        cookie.setValue(pair.getValue());
        cookies.add(cookie);
      }
    }
    return cookies;
  }
View Full Code Here

Examples of org.browsermob.core.har.HarCookie

        // set the cookie on the server side
        IOUtils.readFully(client.execute(new HttpGet("http://127.0.0.1:8080/cookie/")).getEntity().getContent());

        Har har = proxy.getHar();
        HarEntry entry = har.getLog().getEntries().get(0);
        HarCookie cookie = entry.getResponse().getCookies().get(0);
        Assert.assertEquals("foo", cookie.getName());
        Assert.assertEquals("bar", cookie.getValue());
    }
View Full Code Here

Examples of org.browsermob.core.har.HarCookie

        String body = IOUtils.readFully(client.execute(new HttpGet("http://127.0.0.1:8080/echo/")).getEntity().getContent());
        System.out.println(body);

        Har har = proxy.getHar();
        HarEntry entry = har.getLog().getEntries().get(0);
        HarCookie harCookie = entry.getRequest().getCookies().get(0);
        Assert.assertEquals("foo", harCookie.getName());
        Assert.assertEquals("bar", harCookie.getValue());
    }
View Full Code Here

Examples of org.browsermob.core.har.HarCookie

import java.util.List;

public class BlankCookieStore implements CookieStore {
    @Override
    public void addCookie(Cookie cookie) {
        HarCookie hc = new HarCookie();
        hc.setDomain(cookie.getDomain());
        hc.setExpires(cookie.getExpiryDate());
        hc.setName(cookie.getName());
        hc.setValue(cookie.getValue());
        hc.setPath(cookie.getPath());
        RequestInfo.get().getEntry().getResponse().getCookies().add(hc);
    }
View Full Code Here

Examples of org.browsermob.core.har.HarCookie

        List<HarCookie> cookies = newLinkedList();
        for(Header hdr : request.getHeaders("Cookie")) {
            String[] pairs = hdr.getValue().split("; ");
            for (String p : pairs) {
                HarNameValuePair pair = nameValuePair(p);
                HarCookie cookie = new HarCookie();
                cookie.setName(pair.getName());
                cookie.setValue(pair.getValue());
                cookies.add(cookie);
            }
        }
        return cookies;
    }
View Full Code Here

Examples of org.browsermob.core.har.HarCookie

       
        //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);         
              }
            }
        }
View Full Code Here

Examples of org.browsermob.core.har.HarCookie

            }
        }
    }
       
    private HarCookie toHarCookie(Cookie c) {
        HarCookie hc = new HarCookie();
        hc.setName(c.getName());
        hc.setPath(c.getPath());
        hc.setValue(c.getValue());
        hc.setDomain(c.getDomain());
        hc.setExpires(c.getExpiryDate());
        return hc;     
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.