org.browsermob.proxy.ProxyBlockUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of browsermob-proxy Show documentation
Show all versions of browsermob-proxy Show documentation
A programmatic HTTP/S designed for performance and functional testing
package org.browsermob.proxy;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
/** Functions that hope to be useful in dealing with lists of Blocks */
public class ProxyBlockUtil {
public static List collapseBlocks(List blocks) {
List httpObjects = new ArrayList();
for (Block block: blocks) {
List objs = block.getObjects();
for (HttpObject obj: objs) {
httpObjects.add(obj);
}
}
Collections.reverse(httpObjects);
return httpObjects;
}
// returns the first match... null if none found
public static HttpObject getExact(String toFind, List httpObjects) {
for (HttpObject obj: httpObjects) {
if (obj.getUrl().equals(toFind)) {
return obj;
}
}
return null;
}
public static HttpObject getUrlMatch(String toFind, List httpObjects) {
for (HttpObject obj: httpObjects) {
if (obj.getUrl().indexOf(toFind) != -1) {
return obj;
}
}
return null;
}
}