org.apache.synapse.transport.netty.util

## Class RequestResponseUtils

- java.lang.Object
- - org.apache.synapse.transport.netty.util.RequestResponseUtils

-     public class RequestResponseUtils
      extends java.lang.Object

  `RequestResponseUtils` contains utilities used in request and response message flow.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `RequestResponseUtils()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static org.apache.axis2.context.MessageContext` | `convertCarbonMsgToAxis2MsgCtx(org.wso2.transport.http.netty.message.HttpCarbonMessage incomingCarbonMsg, SourceConfiguration sourceConfiguration)` Create an Axis2 message context for the given HttpCarbonMessage.
    `static org.apache.axis2.addressing.EndpointReference` | `getDestinationEPR(org.apache.axis2.context.MessageContext msgContext)` Get the EPR for the message passed in.
    `static org.wso2.transport.http.netty.contract.config.ListenerConfiguration` | `getListenerConfig(SourceConfiguration sourceConfiguration, boolean sslEnabled)` Returns Listener configuration instance populated with source configuration.
    `static java.lang.String` | `getListenerInterface(java.lang.String host, int port)`
    `static java.lang.String` | `getRestUrlPostfix(java.lang.String uri, java.lang.String servicePath)` Generate the REST_URL_POSTFIX from the request URI.
    `static java.lang.String` | `getValueOfElementWithLocalName(org.apache.axiom.om.OMElement element, java.lang.String localName)`
    `static void` | `handleException(java.lang.String msg)`
    `static void` | `handleException(java.lang.String s, java.lang.Exception e)`
    `static boolean` | `isHTTPAccessLoggerEnabled()`
    `static boolean` | `isHttpCarbonMessagePresent(org.apache.axis2.context.MessageContext msgContext)` Check if the HTTP_CARBON_MESSAGE is present in the message context.
    `static boolean` | `isHTTPTraceLoggerEnabled()`
    `static boolean` | `isMultipartContent(java.lang.String contentType)` Check whether the content type is multipart or not.
    `static boolean` | `isRESTRequest(org.apache.axis2.context.MessageContext msgContext, java.lang.String contentType, int soapVersion, java.lang.String soapActionHeader)` Checks if the request should be considered as REST.
    `static boolean` | `isRESTSupportedMediaType(java.lang.String contentType)` Checks if the HTTP request is REST based on the given Content-Type header.
    `static void` | `populateKeyStoreConfigs(org.apache.axiom.om.OMElement keyStoreEl, org.wso2.transport.http.netty.contract.config.SslConfiguration sslConfiguration, org.wso2.securevault.SecretResolver secretResolver)`
    `static int` | `populateSOAPVersion(org.apache.axis2.context.MessageContext msgContext, java.lang.String contentType)` Populates the SOAP version based on the given Content-Type.
    `static void` | `populateTrustStoreConfigs(org.apache.axiom.om.OMElement trustStoreEl, org.wso2.transport.http.netty.contract.config.SslConfiguration sslConfiguration, org.wso2.securevault.SecretResolver secretResolver)`
    `static void` | `setInboundMgsSizeValidationConfig(int maxInitialLineLength, int maxHeaderSize, int maxEntityBodySize, org.wso2.transport.http.netty.contract.config.InboundMsgSizeValidationConfig sizeValidationConfig)` Sets the configuration for the inbound request and response size validation.
    `static org.wso2.transport.http.netty.contract.config.ListenerConfiguration` | `setSslConfig(org.apache.axis2.description.TransportInDescription transportIn, org.wso2.transport.http.netty.contract.config.ListenerConfiguration listenerConfiguration, BaseConfiguration sourceConfiguration)`
    `static boolean` | `shouldInvokeFormatterToWriteBody(org.apache.axis2.context.MessageContext msgContext)` Checks if the request/response body should be written using the appropriate message formatter.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### RequestResponseUtils

          public RequestResponseUtils()

  - ### Method Detail

    - #### convertCarbonMsgToAxis2MsgCtx

          public static org.apache.axis2.context.MessageContext convertCarbonMsgToAxis2MsgCtx(org.wso2.transport.http.netty.message.HttpCarbonMessage incomingCarbonMsg,
                                                                                              SourceConfiguration sourceConfiguration)

      Create an Axis2 message context for the given HttpCarbonMessage. The carbon message may be in the process of being streamed.
      Parameters:
        `incomingCarbonMsg` - the http carbon message to be used to create the corresponding Axis2 message context
        `sourceConfiguration` - source configuration
      Returns:
        the Axis2 message context created

    - #### isHttpCarbonMessagePresent

          public static boolean isHttpCarbonMessagePresent(org.apache.axis2.context.MessageContext msgContext)

      Check if the HTTP_CARBON_MESSAGE is present in the message context.
      Parameters:
        `msgContext` - axis2 message context
      Returns:
        true if HTTP_CARBON_MESSAGE is present in the message context, false otherwise

    - #### shouldInvokeFormatterToWriteBody

          public static boolean shouldInvokeFormatterToWriteBody(org.apache.axis2.context.MessageContext msgContext)

      Checks if the request/response body should be written using the appropriate message formatter.
      Parameters:
        `msgContext` - axis2 message context
      Returns:
        true if the request was initiated from a non-http client or if the message has been built. Otherwise, return false if this is pass-through.

    - #### isMultipartContent

          public static boolean isMultipartContent(java.lang.String contentType)

      Check whether the content type is multipart or not.
      Parameters:
        `contentType` - value of the content type
      Returns:
        true for multipart content types

    - #### getRestUrlPostfix

          public static java.lang.String getRestUrlPostfix(java.lang.String uri,
                                                           java.lang.String servicePath)

      Generate the REST_URL_POSTFIX from the request URI.
      Parameters:
        `uri` - the Request URI as a string
        `servicePath` - service path
      Returns:
        REST_URL_POSTFIX as a string

    - #### isRESTSupportedMediaType

          public static boolean isRESTSupportedMediaType(java.lang.String contentType)

      Checks if the HTTP request is REST based on the given Content-Type header.
      Parameters:
        `contentType` - Content-Type header
      Returns:
        whether the HTTP request is REST or not

    - #### populateSOAPVersion

          public static int populateSOAPVersion(org.apache.axis2.context.MessageContext msgContext,
                                                java.lang.String contentType)

      Populates the SOAP version based on the given Content-Type.
      Parameters:
        `msgContext` - axis2 message context
        `contentType` - Content type of the request.
      Returns:
        0 if the content type is null. return 2 if the content type is application/soap+xml. Otherwise 1

    - #### isRESTRequest

          public static boolean isRESTRequest(org.apache.axis2.context.MessageContext msgContext,
                                              java.lang.String contentType,
                                              int soapVersion,
                                              java.lang.String soapActionHeader)

      Checks if the request should be considered as REST.
      Parameters:
        `msgContext` - axis2 message context
        `contentType` - content-type of the request
        `soapVersion` - SOAP version
        `soapActionHeader` - SOAPAction header
      Returns:
        whether the request should be considered as REST

    - #### 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

    - #### getListenerConfig

          public static org.wso2.transport.http.netty.contract.config.ListenerConfiguration getListenerConfig(SourceConfiguration sourceConfiguration,
                                                                                                              boolean sslEnabled)
                                                                                                       throws org.apache.axis2.AxisFault

      Returns Listener configuration instance populated with source configuration.
      Parameters:
        `sourceConfiguration` - source configuration
      Returns:
        transport listener configuration instance
      Throws:
        `org.apache.axis2.AxisFault`

    - #### isHTTPTraceLoggerEnabled

          public static boolean isHTTPTraceLoggerEnabled()

    - #### isHTTPAccessLoggerEnabled

          public static boolean isHTTPAccessLoggerEnabled()

    - #### setSslConfig

          public static org.wso2.transport.http.netty.contract.config.ListenerConfiguration setSslConfig(org.apache.axis2.description.TransportInDescription transportIn,
                                                                                                         org.wso2.transport.http.netty.contract.config.ListenerConfiguration listenerConfiguration,
                                                                                                         BaseConfiguration sourceConfiguration)
                                                                                                  throws org.apache.axis2.AxisFault

      Throws:
        `org.apache.axis2.AxisFault`

    - #### populateKeyStoreConfigs

          public static void populateKeyStoreConfigs(org.apache.axiom.om.OMElement keyStoreEl,
                                                     org.wso2.transport.http.netty.contract.config.SslConfiguration sslConfiguration,
                                                     org.wso2.securevault.SecretResolver secretResolver)
                                              throws org.apache.axis2.AxisFault

      Throws:
        `org.apache.axis2.AxisFault`

    - #### populateTrustStoreConfigs

          public static void populateTrustStoreConfigs(org.apache.axiom.om.OMElement trustStoreEl,
                                                       org.wso2.transport.http.netty.contract.config.SslConfiguration sslConfiguration,
                                                       org.wso2.securevault.SecretResolver secretResolver)
                                                throws org.apache.axis2.AxisFault

      Throws:
        `org.apache.axis2.AxisFault`

    - #### setInboundMgsSizeValidationConfig

          public static void setInboundMgsSizeValidationConfig(int maxInitialLineLength,
                                                               int maxHeaderSize,
                                                               int maxEntityBodySize,
                                                               org.wso2.transport.http.netty.contract.config.InboundMsgSizeValidationConfig sizeValidationConfig)
                                                        throws org.apache.axis2.AxisFault

      Sets the configuration for the inbound request and response size validation.
      Parameters:
        `maxInitialLineLength` - The maximum length of the initial line (e.g. `"GET / HTTP/1.0"` or `"HTTP/1.0 200 OK"`)
        `maxHeaderSize` - The maximum length of all headers.
        `maxEntityBodySize` - The maximum length of the content or each chunk.
        `sizeValidationConfig` - instance that represents the configuration for the inbound request and response size validation.
      Throws:
        `org.apache.axis2.AxisFault` - when the given values are invalid.

    - #### getValueOfElementWithLocalName

          public static java.lang.String getValueOfElementWithLocalName(org.apache.axiom.om.OMElement element,
                                                                        java.lang.String localName)

    - #### getListenerInterface

          public static java.lang.String getListenerInterface(java.lang.String host,
                                                              int port)

    - #### handleException

          public static void handleException(java.lang.String s,
                                             java.lang.Exception e)
                                      throws org.apache.axis2.AxisFault

      Throws:
        `org.apache.axis2.AxisFault`

    - #### handleException

          public static void handleException(java.lang.String msg)
                                      throws org.apache.axis2.AxisFault

      Throws:
        `org.apache.axis2.AxisFault`

Copyright © 2005-2022 Apache Software Foundation. All Rights Reserved.