/** * Tell whether the default port for the specified protocol is used * * @return true if the default port number for the protocol is used, false otherwise */ public boolean isProtocolDefaultPort() { final int port = getPortIfSpecified(); final String protocol = getProtocol(); boolean isDefaultHTTPPort = HTTPConstants.PROTOCOL_HTTP .equalsIgnoreCase(protocol) && port == HTTPConstants.DEFAULT_HTTP_PORT; boolean isDefaultHTTPSPort = HTTPConstants.PROTOCOL_HTTPS .equalsIgnoreCase(protocol) && port == HTTPConstants.DEFAULT_HTTPS_PORT; return port == UNSPECIFIED_PORT || isDefaultHTTPPort || isDefaultHTTPSPort; }
/** * Get the port; apply the default for the protocol if necessary. * * @return the port number, with default applied if required. */ public int getPort() { final int port = getPortIfSpecified(); if (port == UNSPECIFIED_PORT) { String prot = getProtocol(); if (HTTPConstants.PROTOCOL_HTTPS.equalsIgnoreCase(prot)) { return HTTPConstants.DEFAULT_HTTPS_PORT; } if (!HTTPConstants.PROTOCOL_HTTP.equalsIgnoreCase(prot)) { log.warn("Unexpected protocol: " + prot); // TODO - should this return something else? } return HTTPConstants.DEFAULT_HTTP_PORT; } return port; }
public static HTTPAbstractImpl getImplementation(String impl, HTTPSamplerBase base){ if (HTTPSamplerBase.PROTOCOL_FILE.equals(base.getProtocol())) { return new HTTPFileImpl(base); } if (JOrphanUtils.isBlank(impl)){ impl = DEFAULT_CLASSNAME; } if (IMPL_JAVA.equals(impl) || HTTP_SAMPLER_JAVA.equals(impl)) { return new HTTPJavaImpl(base); } else if (IMPL_HTTP_CLIENT4.equals(impl) || IMPL_HTTP_CLIENT3_1.equals(impl)) { return new HTTPHC4Impl(base); } else { throw new IllegalArgumentException("Unknown implementation type: '"+impl+"'"); } }
String protocol = getProtocol(); String method = getMethod(); if (PROTOCOL_FILE.equalsIgnoreCase(protocol)) {
/** * 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); } }
sampler.setArguments(url.getArguments()); sampler.setProtocol(url.getProtocol()); } else { log.debug("No matches found");
final PatternCacheLRU patternCache = JMeterUtils.getPatternCache(); if (!isEqualOrMatches(newLink.getProtocol(), config.getProtocol(), matcher, patternCache)){ return false;
sampler.setProtocol(url.getProtocol()); } else { log.info("No further matches found, stopping test");