/** * Set domain on sampler * @param sampler {@link HTTPSamplerBase} * @param request {@link HttpRequestHdr} */ protected void computeDomain(HTTPSamplerBase sampler, HttpRequestHdr request) { sampler.setDomain(request.serverName()); if (log.isDebugEnabled()) { log.debug("Proxy: setting server: " + sampler.getDomain()); } } }
private String generateMatchUrl(HTTPSamplerBase sampler) { StringBuilder buf = new StringBuilder(sampler.getDomain()); buf.append(':'); // $NON-NLS-1$ buf.append(sampler.getPort()); buf.append(sampler.getPath()); if (sampler.getQueryString().length() > 0) { buf.append('?'); // $NON-NLS-1$ buf.append(sampler.getQueryString()); } return buf.toString(); }
return new URL(path); String domain = getDomain(); String protocol = getProtocol(); String method = getMethod();
private void addURL(HTTPSamplerBase newUrl) { if (baseDomain == null) { baseDomain = newUrl.getDomain(); if (log.isDebugEnabled()) { log.debug("Base domain: " + baseDomain); } } if (!newUrl.getDomain().equals(baseDomain)) { if (log.isDebugEnabled()) { //log.debug("Skip external: " + newUrl.toString()); } return; } String key = getKeyForURL(newUrl); if (!URLs.containsKey(key)) { URLs.put(key, newUrl); marks.add(key); if (log.isDebugEnabled()) { log.debug("Put: " + newUrl.toString()); } } else { if (log.isDebugEnabled()) { // log.debug("Skip existing: " + newUrl.toString()); } } }
/** * Compute content encoding * @param sampler {@link HTTPSamplerBase} * @param request {@link HttpRequestHdr} * @param pageEncodings Map of page encodings * @param formEncodings Map of form encodings * @throws MalformedURLException when no {@link URL} could be built from * <code>sampler</code> and <code>request</code> */ protected void computeContentEncoding(HTTPSamplerBase sampler, HttpRequestHdr request, Map<String, String> pageEncodings, Map<String, String> formEncodings) throws MalformedURLException { URL pageUrl = null; if(sampler.isProtocolDefaultPort()) { pageUrl = new URL(sampler.getProtocol(), sampler.getDomain(), request.getPath()); } else { pageUrl = new URL(sampler.getProtocol(), sampler.getDomain(), sampler.getPort(), request.getPath()); } String urlWithoutQuery = request.getUrlWithoutQuery(pageUrl); String contentEncoding = computeContentEncoding(request, pageEncodings, formEncodings, urlWithoutQuery); // Set the content encoding if(!StringUtils.isEmpty(contentEncoding)) { sampler.setContentEncoding(contentEncoding); } }
boolean filterUrl(HTTPSamplerBase sampler) { String domain = sampler.getDomain(); if (domain == null || domain.length() == 0) { return false; } String url = generateMatchUrl(sampler); CollectionProperty includePatterns = getIncludePatterns(); if (includePatterns.size() > 0 && !matchesPatterns(url, includePatterns)) { return false; } CollectionProperty excludePatterns = getExcludePatterns(); if (excludePatterns.size() > 0 && matchesPatterns(url, excludePatterns)) { return false; } return true; }
log.debug("Selected: "+url.toString()); sampler.setDomain(url.getDomain()); sampler.setPath(url.getPath()); if (url.getMethod().equals(HTTPConstants.POST)) {
sampler.setDomain(url.getDomain()); sampler.setPath(url.getPath()); if (url.getMethod().equals(HTTPConstants.POST)) {