/** * Compute sampler name * * @param sampler {@link HTTPSamplerBase} * @param request {@link HttpRequestHdr} */ protected void computeSamplerName(HTTPSamplerBase sampler, HttpRequestHdr request) { if (!HTTPConstants.CONNECT.equals(request.getMethod()) && isNumberRequests()) { incrementRequestNumber(); sampler.setName(getRequestNumber() + " " + sampler.getPath()); } else { sampler.setName(sampler.getPath()); } }
/** * Set path on sampler * * @param sampler {@link HTTPSamplerBase} * @param request {@link HttpRequestHdr} */ protected void computePath(HTTPSamplerBase sampler, HttpRequestHdr request) { if (sampler.getContentEncoding() != null) { sampler.setPath(request.getPath(), sampler.getContentEncoding()); } else { // Although the spec says UTF-8 should be used for encoding URL parameters, // most browser use ISO-8859-1 for default if encoding is not known. // We use null for contentEncoding, then the url parameters will be added // with the value in the URL, and the "encode?" flag set to false sampler.setPath(request.getPath(), null); } if (log.isDebugEnabled()) { log.debug("Proxy: setting path: " + sampler.getPath()); } }
/** * @see * org.apache.jmeter.protocol.http.proxy.SamplerCreator#populateSampler(org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase, * org.apache.jmeter.protocol.http.proxy.HttpRequestHdr, java.util.Map, java.util.Map) */ @Override public final void populateSampler( HTTPSamplerBase sampler, HttpRequestHdr request, Map<String, String> pageEncodings, Map<String, String> formEncodings) throws Exception { computeFromHeader(sampler, request, pageEncodings, formEncodings); computeFromPostBody(sampler, request); if (log.isDebugEnabled()) { log.debug("sampler path = " + sampler.getPath()); } Arguments arguments = sampler.getArguments(); if (arguments.getArgumentCount() == 1 && arguments.getArgument(0).getName().length() == 0) { sampler.setPostBodyRaw(true); } }
/** * @see * org.apache.jmeter.protocol.http.proxy.SamplerCreator#createSampler(org.apache.jmeter.protocol.http.proxy.HttpRequestHdr, * java.util.Map, java.util.Map) */ @Override public HTTPSamplerBase createSampler( HttpRequestHdr request, Map<String, String> pageEncodings, Map<String, String> formEncodings) { // Instantiate the sampler HTTPSamplerBase sampler = HTTPSamplerFactory.newInstance(request.getHttpSamplerName()); sampler.setProperty(TestElement.GUI_CLASS, HttpTestSampleGui.class.getName()); // Defaults sampler.setFollowRedirects(false); sampler.setUseKeepAlive(true); if (log.isDebugEnabled()) { log.debug("getSampler: sampler path = " + sampler.getPath()); } return sampler; }