Package org.apache.jmeter.protocol.http.proxy

# Class DefaultSamplerCreator

java.lang.Object
org.apache.jmeter.protocol.http.proxy.AbstractSamplerCreator
org.apache.jmeter.protocol.http.proxy.DefaultSamplerCreator

All Implemented Interfaces:
  `SamplerCreator`

@AutoService(SamplerCreator.class) public class DefaultSamplerCreator extends AbstractSamplerCreator
Default implementation that handles classical HTTP textual + Multipart requests

## Field Summary

### Fields inherited from class org.apache.jmeter.protocol.http.proxy.AbstractSamplerCreator

`DEFAULT_ENCODING_KEY, HTTP, HTTPS`

## Constructor Summary

Constructors
Constructor
Description
`DefaultSamplerCreator()`

## Method Summary

Modifier and Type
Method
Description
`protected String`
`computeContentEncoding(HttpRequestHdr request, Map<String,String> pageEncodings, Map<String,String> formEncodings, String urlWithoutQuery)`
Computes content encoding from request and if not found uses pageEncoding and formEncoding to see if URL was previously computed with a content type
`protected void`
`computeContentEncoding(HTTPSamplerBase sampler, HttpRequestHdr request, Map<String,String> pageEncodings, Map<String,String> formEncodings)`
Compute content encoding
`protected void`
`computeDomain(HTTPSamplerBase sampler, HttpRequestHdr request)`
Set domain on sampler
`protected void`
`computeFromHeader(HTTPSamplerBase sampler, HttpRequestHdr request, Map<String,String> pageEncodings, Map<String,String> formEncodings)`
Compute sampler information from Request Header
`protected void`
`computeFromPostBody(HTTPSamplerBase sampler, HttpRequestHdr request)`
Compute sampler information from Request Header
`protected void`
`computeMethod(HTTPSamplerBase sampler, HttpRequestHdr request)`
Set method on sampler
`protected void`
`computePath(HTTPSamplerBase sampler, HttpRequestHdr request)`
Set path on sampler
`protected void`
`computePort(HTTPSamplerBase sampler, HttpRequestHdr request)`
Set Port on sampler
`protected void`
`computeProtocol(HTTPSamplerBase sampler, HttpRequestHdr request)`
Set protocol on sampler
`protected static void`
`computeSamplerName(HTTPSamplerBase sampler, HttpRequestHdr request)`
Compute sampler name
`HTTPSamplerBase`
`createSampler(HttpRequestHdr request, Map<String,String> pageEncodings, Map<String,String> formEncodings)`
Create HTTPSamplerBase
`String[]`
`getManagedContentTypes()`
`static boolean`
`isPotentialJson(String postData)`
Tries parsing to see if content is JSON
`final void`
`populateSampler(HTTPSamplerBase sampler, HttpRequestHdr request, Map<String,String> pageEncodings, Map<String,String> formEncodings)`
Populate sampler from request

### Methods inherited from class org.apache.jmeter.protocol.http.proxy.AbstractSamplerCreator

`createAndPopulateSampler, createChildren, getBinaryDirectory, getBinaryFileSuffix, getRequestNumber, incrementRequestNumber, incrementRequestNumberAndGet, isBinaryContent, isNumberRequests, postProcessSampler, setCounter`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### DefaultSamplerCreator

public DefaultSamplerCreator()

## Method Details

### getManagedContentTypes

public String[] getManagedContentTypes()

Returns:
  String[] array of Content types managed by Factory
See Also:
  - `SamplerCreator.getManagedContentTypes()`

### createSampler

public HTTPSamplerBase createSampler(HttpRequestHdr request, Map<String,String> pageEncodings, Map<String,String> formEncodings)
Description copied from interface: `SamplerCreator`
Create HTTPSamplerBase

Parameters:
  `request` - `HttpRequestHdr`
  `pageEncodings` - Map of page encodings
  `formEncodings` - Map of form encodings
Returns:
  `HTTPSamplerBase`
See Also:
  - `SamplerCreator.createSampler(org.apache.jmeter.protocol.http.proxy.HttpRequestHdr, java.util.Map, java.util.Map)`

### populateSampler

public final void populateSampler(HTTPSamplerBase sampler, HttpRequestHdr request, Map<String,String> pageEncodings, Map<String,String> formEncodings) throws Exception
Description copied from interface: `SamplerCreator`
Populate sampler from request

Parameters:
  `sampler` - `HTTPSamplerBase`
  `request` - `HttpRequestHdr`
  `pageEncodings` - Map of page encodings
  `formEncodings` - Map of form encodings
Throws:
  `Exception` - when something fails
See Also:
  - `SamplerCreator.populateSampler(org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase, org.apache.jmeter.protocol.http.proxy.HttpRequestHdr, java.util.Map, java.util.Map)`

### computeFromHeader

protected void computeFromHeader(HTTPSamplerBase sampler, HttpRequestHdr request, Map<String,String> pageEncodings, Map<String,String> formEncodings) throws Exception
Compute sampler information from Request Header

Parameters:
  `sampler` - `HTTPSamplerBase`
  `request` - `HttpRequestHdr`
  `pageEncodings` - Map of page encodings
  `formEncodings` - Map of form encodings
Throws:
  `Exception` - when something fails

### computeFromPostBody

protected void computeFromPostBody(HTTPSamplerBase sampler, HttpRequestHdr request) throws Exception
Compute sampler information from Request Header

Parameters:
  `sampler` - `HTTPSamplerBase`
  `request` - `HttpRequestHdr`
Throws:
  `Exception` - when something fails

### isPotentialJson

public static boolean isPotentialJson(String postData)
Tries parsing to see if content is JSON

Parameters:
  `postData` - String
Returns:
  boolean

### computeSamplerName

protected static void computeSamplerName(HTTPSamplerBase sampler, HttpRequestHdr request)
Compute sampler name

Parameters:
  `sampler` - `HTTPSamplerBase`
  `request` - `HttpRequestHdr`

### computePath

protected void computePath(HTTPSamplerBase sampler, HttpRequestHdr request)
Set path on sampler

Parameters:
  `sampler` - `HTTPSamplerBase`
  `request` - `HttpRequestHdr`

### computeContentEncoding

protected void computeContentEncoding(HTTPSamplerBase sampler, HttpRequestHdr request, Map<String,String> pageEncodings, Map<String,String> formEncodings) throws MalformedURLException
Compute content encoding

Parameters:
  `sampler` - `HTTPSamplerBase`
  `request` - `HttpRequestHdr`
  `pageEncodings` - Map of page encodings
  `formEncodings` - Map of form encodings
Throws:
  `MalformedURLException` - when no `URL` could be built from `sampler` and `request`

### computeContentEncoding

protected String computeContentEncoding(HttpRequestHdr request, Map<String,String> pageEncodings, Map<String,String> formEncodings, String urlWithoutQuery)
Computes content encoding from request and if not found uses pageEncoding and formEncoding to see if URL was previously computed with a content type

Parameters:
  `request` - `HttpRequestHdr`
  `pageEncodings` - Map of page encodings
  `formEncodings` - Map of form encodings
  `urlWithoutQuery` - the request URL without the query parameters
Returns:
  String content encoding

### computeProtocol

protected void computeProtocol(HTTPSamplerBase sampler, HttpRequestHdr request)
Set protocol on sampler

Parameters:
  `sampler` - `HTTPSamplerBase`
  `request` - `HttpRequestHdr`

### computePort

protected void computePort(HTTPSamplerBase sampler, HttpRequestHdr request)
Set Port on sampler

Parameters:
  `sampler` - `HTTPSamplerBase`
  `request` - `HttpRequestHdr`

### computeMethod

protected void computeMethod(HTTPSamplerBase sampler, HttpRequestHdr request)
Set method on sampler

Parameters:
  `sampler` - `HTTPSamplerBase`
  `request` - `HttpRequestHdr`

### computeDomain

protected void computeDomain(HTTPSamplerBase sampler, HttpRequestHdr request)
Set domain on sampler

Parameters:
  `sampler` - `HTTPSamplerBase`
  `request` - `HttpRequestHdr`