Class NhttpUtil
java.lang.Object
org.apache.synapse.transport.nhttp.util.NhttpUtil
A useful set of utility methods for the HTTP transport
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetContentType(org.apache.axis2.context.MessageContext msgContext) Get the content type for the message passed instatic org.apache.axis2.addressing.EndpointReferencegetDestinationEPR(org.apache.axis2.context.MessageContext msgContext) Get the EPR for the message passed instatic StringgetHostName(InetAddress address) This method tries to determine the hostname of the given InetAddress without triggering a reverse DNS lookup.static org.apache.axiom.om.OMOutputFormatgetOMOutputFormat(org.apache.axis2.context.MessageContext msgContext) Retirn the OMOutputFormat to be used for the message context passed instatic StringgetRestUrlPostfix(String uri, String servicePath) Calculate the REST_URL_POSTFIX from the request URI
-
Constructor Details
-
NhttpUtil
public NhttpUtil()
-
-
Method Details
-
getHostName
This method tries to determine the hostname of the given InetAddress without triggering a reverse DNS lookup.InetAddress.getHostName()triggers a reverse DNS lookup which can be very costly in cases where reverse DNS fails. Tries to parse a symbolic hostname fromInetAddress.toString(), which is documented to return a String of the form "hostname / literal IP address" with 'hostname' blank if not already computed invalid input: '&' stored inaddressinvalid input: '<'/codeinvalid input: '<'. If the hostname cannot be determined from InetAddress.toString(), the value ofInetAddress.getHostAddress()is returned.- Parameters:
address- The InetAddress whose hostname has to be determined- Returns:
- hostsname, if it can be determined. hostaddress, if not. TODO: We may introduce a System property or some other method of configuration TODO: which will specify whether to allow reverse DNS lookup or not
-
getDestinationEPR
public static org.apache.axis2.addressing.EndpointReference getDestinationEPR(org.apache.axis2.context.MessageContext msgContext) Get the EPR for the message passed in- Parameters:
msgContext- the message context- Returns:
- the destination EPR
-
getOMOutputFormat
public static org.apache.axiom.om.OMOutputFormat getOMOutputFormat(org.apache.axis2.context.MessageContext msgContext) Retirn the OMOutputFormat to be used for the message context passed in- Parameters:
msgContext- the message context- Returns:
- the OMOutputFormat to be used
-
getContentType
Get the content type for the message passed in- Parameters:
msgContext- the message- Returns:
- content type of the message
-
getRestUrlPostfix
Calculate the REST_URL_POSTFIX from the request URI- Parameters:
uri- - The Request URI - StringservicePath- String- Returns:
- REST_URL_POSTFIX String
-