/** * @param sampler {@link HTTPSamplerBase} * @return String Protocol (http or https) */ public String getProtocol(HTTPSamplerBase sampler) { if (url.contains("//")) { String protocol = url.substring(0, url.indexOf(':')); if (log.isDebugEnabled()) { log.debug("Proxy: setting protocol to : " + protocol); } return protocol; } else if (sampler.getPort() == HTTPConstants.DEFAULT_HTTPS_PORT) { if (log.isDebugEnabled()) { log.debug("Proxy: setting protocol to https"); } return HTTPS; } else { if (log.isDebugEnabled()) { log.debug("Proxy setting default protocol to: http"); } return HTTP; } }
/** * Set Port on sampler * @param sampler {@link HTTPSamplerBase} * @param request {@link HttpRequestHdr} */ protected void computePort(HTTPSamplerBase sampler, HttpRequestHdr request) { sampler.setPort(request.serverPort()); if (log.isDebugEnabled()) { log.debug("Proxy: setting port: " + sampler.getPort()); } }
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(protocol, domain, pathAndQuery.toString()); return new URL(protocol, domain, getPort(), pathAndQuery.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); } }