Class NettyHttpHelper
- java.lang.Object
-
- org.apache.camel.component.netty.http.NettyHttpHelper
-
public final class NettyHttpHelper extends Object
Helpers.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidappendHeader(Map<String,Object> headers, String key, Object value)Appends the key/value to the headers.static io.netty.handler.codec.http.HttpMethodcreateMethod(org.apache.camel.Message message, boolean hasPayload)Creates theHttpMethodto use to call the remote server, often either its GET or POST.static URIcreateURI(org.apache.camel.Exchange exchange, String url, NettyHttpEndpoint endpoint)Creates the URI to invoke.static StringcreateURL(org.apache.camel.Exchange exchange, NettyHttpEndpoint endpoint)Creates the URL to invoke.static ObjectdeserializeJavaObjectFromStream(InputStream is)static StringgetCharsetFromContentType(String contentType)static booleanisStatusCodeOk(int statusCode, String okStatusCodeRange)Checks whether the given http status code is within the ok rangestatic ExceptionpopulateNettyHttpOperationFailedException(org.apache.camel.Exchange exchange, String url, io.netty.handler.codec.http.FullHttpResponse response, int responseCode, boolean transferException)static voidsetCharsetFromContentType(String contentType, org.apache.camel.Exchange exchange)
-
-
-
Method Detail
-
setCharsetFromContentType
public static void setCharsetFromContentType(String contentType, org.apache.camel.Exchange exchange)
-
appendHeader
public static void appendHeader(Map<String,Object> headers, String key, Object value)
Appends the key/value to the headers. This implementation supports keys with multiple values. In such situations the value will be aListthat contains the multiple values.- Parameters:
headers- headerskey- the keyvalue- the value
-
createMethod
public static io.netty.handler.codec.http.HttpMethod createMethod(org.apache.camel.Message message, boolean hasPayload)Creates theHttpMethodto use to call the remote server, often either its GET or POST.- Parameters:
message- the Camel message- Returns:
- the created method
-
populateNettyHttpOperationFailedException
public static Exception populateNettyHttpOperationFailedException(org.apache.camel.Exchange exchange, String url, io.netty.handler.codec.http.FullHttpResponse response, int responseCode, boolean transferException)
-
deserializeJavaObjectFromStream
public static Object deserializeJavaObjectFromStream(InputStream is) throws ClassNotFoundException, IOException
- Throws:
ClassNotFoundExceptionIOException
-
createURL
public static String createURL(org.apache.camel.Exchange exchange, NettyHttpEndpoint endpoint)
Creates the URL to invoke.- Parameters:
exchange- the exchangeendpoint- the endpoint- Returns:
- the URL to invoke
-
createURI
public static URI createURI(org.apache.camel.Exchange exchange, String url, NettyHttpEndpoint endpoint) throws URISyntaxException
Creates the URI to invoke.- Parameters:
exchange- the exchangeurl- the url to invokeendpoint- the endpoint- Returns:
- the URI to invoke
- Throws:
URISyntaxException
-
isStatusCodeOk
public static boolean isStatusCodeOk(int statusCode, String okStatusCodeRange)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
-
-