Class ConversionUtils
java.lang.Object
org.apache.jmeter.protocol.http.util.ConversionUtils
General purpose conversion utilities related to HTTP/HTML
- 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionstatic StringencodeWithEntities(String value, Charset charset) Encodes non-encodable characters as HTML entities like e.g.static Stringstatic StringgetEncodingFromContentType(String contentType) Extract the encoding (charset) from the Content-Type, e.g.static URLmakeRelativeURL(URL baseURL, String location) Generate an absolute URL from a possibly relative location, allowing for extraneous leading "../" segments.static StringpercentEncode(String value) Encodes strings formultipart/form-datanames and values.static StringremoveSlashDotDot(String url) collapses absolute or relative URLs containing '/..' convertinghttp://host/path1/../path2tohttp://host/path2or/one/two/../threeto/one/threestatic URIsanitizeUrl(URL url) Checks a URL and encodes it if necessary, i.e. 
- 
Constructor Details
- 
ConversionUtils
public ConversionUtils() 
 - 
 - 
Method Details
- 
getEncodingFromContentType
Extract the encoding (charset) from the Content-Type, e.g. "text/html; charset=utf-8".- Parameters:
 contentType- string from which the encoding should be extracted- Returns:
 - the charset encoding - or 
null, if none was found or the charset is not supported - Throws:
 IllegalCharsetNameException- if the found charset is not supported
 - 
percentEncode
Encodes strings formultipart/form-datanames and values. The encoding is"as%22,CRas%0D, andLFas%0A. Note:%is not encoded, so it creates ambiguity which might be resolved in a later specification version.- Parameters:
 value- input value to convert- Returns:
 - converted value
 - Since:
 - 5.6
 - See Also:
 
 - 
encodeWithEntities
@API(status=EXPERIMENTAL, since="5.6.1") public static String encodeWithEntities(String value, Charset charset) Encodes non-encodable characters as HTML entities like e.g. 😂 for 😂.- Parameters:
 value- value to encodecharset- charset that will be used for encoding, defaults to UTF-8 if null- Returns:
 - input value with non-encodable characters replaced with HTML entities
 
 - 
makeRelativeURL
Generate an absolute URL from a possibly relative location, allowing for extraneous leading "../" segments. The JavaURL(URL, String)constructor does not remove these.- Parameters:
 baseURL- the base URL which is used to resolve missing protocol/host in the locationlocation- the location, possibly with extraneous leading "../"- Returns:
 - URL with extraneous ../ removed
 - Throws:
 MalformedURLException- when the givenURLis malformed- See Also:
 
 - 
escapeIllegalURLCharacters
- Parameters:
 url- String Url to escape- Returns:
 - String cleaned up url
 - Throws:
 Exception- when givenurlleads to a malformed URL or URI
 - 
sanitizeUrl
Checks a URL and encodes it if necessary, i.e. if it is not currently correctly encoded. Warning: it may not work on all unencoded URLs.- Parameters:
 url- non-encoded URL- Returns:
 - URI which has been encoded as necessary
 - Throws:
 URISyntaxException- if parts of the url form a non valid URI
 - 
removeSlashDotDot
collapses absolute or relative URLs containing '/..' convertinghttp://host/path1/../path2tohttp://host/path2or/one/two/../threeto/one/three- Parameters:
 url- in which the '/..'s should be removed- Returns:
 - collapsed URL
 - See Also:
 
 
 -