public final class HttpHelper extends Object
Modifier and Type | Method and Description |
---|---|
static void |
appendHeader(Map<String,Object> headers,
String key,
Object value)
Appends the key/value to the headers.
|
static HttpMethods |
createMethod(org.apache.camel.Exchange exchange,
HttpCommonEndpoint endpoint,
boolean hasPayload)
Creates the HttpMethod to use to call the remote server, often either its GET or POST.
|
static URI |
createURI(org.apache.camel.Exchange exchange,
String url,
HttpCommonEndpoint endpoint)
Creates the URI to invoke.
|
static String |
createURL(org.apache.camel.Exchange exchange,
HttpCommonEndpoint endpoint)
Creates the URL to invoke.
|
static Object |
deserializeJavaObjectFromStream(InputStream is)
Deprecated.
Camel 3.0
Please use the one which has the parameter of camel context
|
static Object |
deserializeJavaObjectFromStream(InputStream is,
org.apache.camel.CamelContext context)
Deserializes the input stream to a Java object
|
static Object |
extractHttpParameterValue(String value)
Extracts the parameter value.
|
static String |
getCharsetFromContentType(String contentType) |
static boolean |
isSecureConnection(String uri) |
static boolean |
isStatusCodeOk(int statusCode,
String okStatusCodeRange)
Checks whether the given http status code is within the ok range
|
static int[] |
parserHttpVersion(String s) |
static Object |
readRequestBodyFromInputStream(InputStream is,
org.apache.camel.Exchange exchange)
Reads the response body from the given input stream.
|
static Object |
readRequestBodyFromServletRequest(javax.servlet.http.HttpServletRequest request,
org.apache.camel.Exchange exchange)
Reads the response body from the given http servlet request.
|
static Object |
readResponseBodyFromInputStream(InputStream is,
org.apache.camel.Exchange exchange)
Reads the response body from the given input stream.
|
static void |
setCharsetFromContentType(String contentType,
org.apache.camel.Exchange exchange) |
static String |
urlRewrite(org.apache.camel.Exchange exchange,
String url,
HttpCommonEndpoint endpoint,
org.apache.camel.Producer producer)
Processes any custom
UrlRewrite . |
static void |
writeObjectToServletResponse(javax.servlet.ServletResponse response,
Object target)
Writes the given object as response body to the servlet response
The content type will be set to
HttpConstants.CONTENT_TYPE_JAVA_SERIALIZED_OBJECT |
static void |
writeObjectToStream(OutputStream stream,
Object target)
Writes the given object as response body to the output stream
|
public static boolean isSecureConnection(String uri)
public static int[] parserHttpVersion(String s) throws ProtocolException
ProtocolException
public static void setCharsetFromContentType(String contentType, org.apache.camel.Exchange exchange)
public static void writeObjectToServletResponse(javax.servlet.ServletResponse response, Object target) throws IOException
HttpConstants.CONTENT_TYPE_JAVA_SERIALIZED_OBJECT
response
- servlet responsetarget
- object to writeIOException
- is thrown if error writingpublic static void writeObjectToStream(OutputStream stream, Object target) throws IOException
stream
- output streamtarget
- object to writeIOException
- is thrown if error writing@Deprecated public static Object deserializeJavaObjectFromStream(InputStream is) throws ClassNotFoundException, IOException
is
- input stream for the Java objectClassNotFoundException
- is thrown if class not foundIOException
- can be thrownpublic static Object deserializeJavaObjectFromStream(InputStream is, org.apache.camel.CamelContext context) throws ClassNotFoundException, IOException
is
- input stream for the Java objectcontext
- the camel context which could help us to apply the customer classloaderClassNotFoundException
- is thrown if class not foundIOException
- can be thrownpublic static Object readRequestBodyFromServletRequest(javax.servlet.http.HttpServletRequest request, org.apache.camel.Exchange exchange) throws IOException
request
- http servlet requestexchange
- the exchangeIOException
- is thrown if error reading response bodypublic static Object readRequestBodyFromInputStream(InputStream is, org.apache.camel.Exchange exchange) throws IOException
is
- the input streamexchange
- the exchangeIOException
- is thrown if error reading response bodypublic static Object readResponseBodyFromInputStream(InputStream is, org.apache.camel.Exchange exchange) throws IOException
is
- the input streamexchange
- the exchangeIOException
- is thrown if error reading response bodypublic static String createURL(org.apache.camel.Exchange exchange, HttpCommonEndpoint endpoint)
exchange
- the exchangeendpoint
- the endpointpublic static URI createURI(org.apache.camel.Exchange exchange, String url, HttpCommonEndpoint endpoint) throws URISyntaxException
exchange
- the exchangeurl
- the url to invokeendpoint
- the endpointURISyntaxException
public static void appendHeader(Map<String,Object> headers, String key, Object value)
List
that contains the multiple values.headers
- headerskey
- the keyvalue
- the valuepublic static Object extractHttpParameterValue(String value)
List
containing the values.
If the value is not a HTTP mulit value the value is returned as is.value
- the parameter valuepublic static String urlRewrite(org.apache.camel.Exchange exchange, String url, HttpCommonEndpoint endpoint, org.apache.camel.Producer producer) throws Exception
UrlRewrite
.exchange
- the exchangeurl
- the urlendpoint
- the http endpointproducer
- the producerException
- is thrown if any error during rewriting urlpublic static HttpMethods createMethod(org.apache.camel.Exchange exchange, HttpCommonEndpoint endpoint, boolean hasPayload) throws URISyntaxException
exchange
- the exchangeURISyntaxException
public static boolean isStatusCodeOk(int statusCode, String okStatusCodeRange)
statusCode
- the status codeokStatusCodeRange
- the ok range (inclusive)Apache Camel