Package org.apache.camel.support.http
Class HttpUtil
java.lang.Object
org.apache.camel.support.http.HttpUtil
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddCommonFilters(Set<String> filterSet) Add common in/out filters used in HTTP componentsstatic voidapplyHeader(org.apache.camel.spi.HeaderFilterStrategy headerFilterStrategy, org.apache.camel.Exchange exchange, Iterator<?> it, org.apache.camel.TypeConverter tc, String key, BiConsumer<List<String>, String> consumer) Iterates over a list of values and passes them to the consumer after applying the filter strategy.static intdetermineResponseCode(org.apache.camel.Exchange camelExchange, Object body) Given an exchange handling HTTP, determines the status response code to return for the callerstatic booleanfilterCheck(String templateUri, String queryParameters, String headerName, boolean answer) static StringgetCharsetFromContentType(String contentType) Deprecated.static booleanisStatusCodeOk(int statusCode, String okStatusCodeRange) Checks whether the given http status code is within the ok rangestatic booleanparseStatusRange(String range, BiConsumer<Integer, Integer> consumer) Parse a HTTP status range and passes the values to the consumer methodstatic StringrecreateUrl(Map<String, Object> map, String url) Recreates the URL from a map of optionsstatic voidsetCharsetFromContentType(String contentType, org.apache.camel.Exchange exchange) Extracts the charset value from the content type string and sets it on the given exchange
-
Method Details
-
determineResponseCode
Given an exchange handling HTTP, determines the status response code to return for the caller- Parameters:
camelExchange- the exchange to evaluatebody- an optional payload (i.e.: the message body) carrying a response code- Returns:
- An integer value with the response code
-
getCharsetFromContentType
Deprecated.useIOHelper.getCharsetNameFromContentType(String)Deprecated way to extract the charset value from the content type string- Parameters:
contentType- the content type string- Returns:
- the charset value or null if there is nothing to extract
-
setCharsetFromContentType
public static void setCharsetFromContentType(String contentType, org.apache.camel.Exchange exchange) Extracts the charset value from the content type string and sets it on the given exchange- Parameters:
contentType- the content type stringexchange- the exchange to set the charset value
-
recreateUrl
Recreates the URL from a map of options- Parameters:
map- the map of optionsurl- the base URL- Returns:
- the recreated URL
-
addCommonFilters
Add common in/out filters used in HTTP components- Parameters:
filterSet- The set instance containing the out filters
-
isStatusCodeOk
Checks whether the given http status code is within the ok range- Parameters:
statusCode- the status codeokStatusCodeRange- the ok range (inclusive)- Returns:
- true if ok, false otherwise
-
parseStatusRange
Parse a HTTP status range and passes the values to the consumer method- Parameters:
range- the HTTP status range in the format "XXX-YYY" (i.e.: 200-299)consumer- a consumer method to receive the parse ranges- Returns:
- true if the range was parsed or false otherwise
-
applyHeader
public static void applyHeader(org.apache.camel.spi.HeaderFilterStrategy headerFilterStrategy, org.apache.camel.Exchange exchange, Iterator<?> it, org.apache.camel.TypeConverter tc, String key, BiConsumer<List<String>, String> consumer) Iterates over a list of values and passes them to the consumer after applying the filter strategy. This is mostly used to simplify setting headers for HTTP responses- Parameters:
headerFilterStrategy- the filter strategy to applyexchange- an exchange to apply the header strategyit- the iterator providing the valuestc- a type converter instance so that the values can be converted to stringkey- a key associated with the values being iteratedconsumer- a consumer method to receive the converted values. It can receive either a list of values or a single value.
-
filterCheck
-
IOHelper.getCharsetNameFromContentType(String)