org.apache.synapse.transport.netty.util

## Class HttpUtils

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

-     public class HttpUtils
      extends java.lang.Object

  Utility class providing HTTP utility methods.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `HttpUtils()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `addTransportHeadersToTransportMessage(io.netty.handler.codec.http.HttpHeaders headers, org.apache.axis2.context.MessageContext msgCtx)`
    `static void` | `closeMessageOutputStreamQuietly(java.io.OutputStream messageOutputStream)`
    `static void` | `copyContentFromInboundHttpCarbonMessage(org.wso2.transport.http.netty.message.HttpCarbonMessage inboundMsg, org.wso2.transport.http.netty.message.HttpCarbonMessage outboundResponseMsg)`
    `static org.wso2.transport.http.netty.contractimpl.sender.channel.pool.ConnectionManager` | `getConnectionManager()`
    `static org.wso2.transport.http.netty.message.HttpMessageDataStreamer` | `getHttpMessageDataStreamer(org.wso2.transport.http.netty.message.HttpCarbonMessage outboundResponse)` Get the response data streamer that should be used for serializing data.
    `static boolean` | `isCONNECTRequest(org.apache.axis2.context.MessageContext msgCtx)`
    `static boolean` | `isFaultMessage(org.apache.axis2.context.MessageContext msgContext)`
    `static boolean` | `isGETRequest(org.apache.axis2.context.MessageContext msgCtx)`
    `static boolean` | `isHEADRequest(org.apache.axis2.context.MessageContext msgCtx)`
    `static boolean` | `isNoEntityBodyRequest(org.apache.axis2.context.MessageContext msgCtx)`
    `static void` | `populatePoolingConfig(org.wso2.transport.http.netty.contractimpl.sender.channel.pool.PoolConfiguration poolConfiguration)`
    `static void` | `removeUnwantedHeadersFromInternalTransportHeadersMap(org.apache.axis2.context.MessageContext msgContext, BaseConfiguration baseConfiguration)` RRemove unwanted headers from the http response of outgoing request.
    `static boolean` | `requestHasEntityBody(org.wso2.transport.http.netty.message.HttpCarbonMessage httpCarbonMessage)` Checks if the given HttpCarbonMessage has an entity body.
    `static boolean` | `sendFaultAsHTTP200(org.apache.axis2.context.MessageContext msgContext)`
    `static org.wso2.transport.http.netty.contract.HttpResponseFuture` | `sendOutboundResponse(org.wso2.transport.http.netty.message.HttpCarbonMessage requestMsg, org.wso2.transport.http.netty.message.HttpCarbonMessage responseMsg)` Invokes `HttpResponseFuture` respond method to send the response back to the client.
    `static void` | `serializeBytes(java.io.OutputStream outputStream, byte[] bytes)`
    `static void` | `serializeDataUsingMessageFormatter(org.apache.axis2.context.MessageContext msgContext, org.apache.axis2.transport.MessageFormatter messageFormatter, java.io.OutputStream outputStream)`
    `static void` | `setHostHeader(java.lang.String host, int port, io.netty.handler.codec.http.HttpHeaders headers, org.apache.axis2.context.MessageContext msgCtx, boolean isPreservedHeader)`
    `static void` | `writeEmptyBody(java.io.OutputStream outputStream)`

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

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

- - ### Constructor Detail

    - #### HttpUtils

          public HttpUtils()

  - ### Method Detail

    - #### getConnectionManager

          public static org.wso2.transport.http.netty.contractimpl.sender.channel.pool.ConnectionManager getConnectionManager()

    - #### populatePoolingConfig

          public static void populatePoolingConfig(org.wso2.transport.http.netty.contractimpl.sender.channel.pool.PoolConfiguration poolConfiguration)

    - #### removeUnwantedHeadersFromInternalTransportHeadersMap

          public static void removeUnwantedHeadersFromInternalTransportHeadersMap(org.apache.axis2.context.MessageContext msgContext,
                                                                                  BaseConfiguration baseConfiguration)

      RRemove unwanted headers from the http response of outgoing request. These are headers which should be dictated by the transport and not by the user. We remove these as these may get copied from the request messages.
      Parameters:
        `msgContext` - axis2 message context
        `baseConfiguration` - configuration that has all the preserved header details

    - #### isFaultMessage

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

    - #### sendFaultAsHTTP200

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

    - #### requestHasEntityBody

          public static boolean requestHasEntityBody(org.wso2.transport.http.netty.message.HttpCarbonMessage httpCarbonMessage)

      Checks if the given HttpCarbonMessage has an entity body.
      Parameters:
        `httpCarbonMessage` - HttpCarbonMessage in which we need to check if an entity body is present
      Returns:
        true if the HttpCarbonMessage has an entity body enclosed

    - #### sendOutboundResponse

          public static org.wso2.transport.http.netty.contract.HttpResponseFuture sendOutboundResponse(org.wso2.transport.http.netty.message.HttpCarbonMessage requestMsg,
                                                                                                       org.wso2.transport.http.netty.message.HttpCarbonMessage responseMsg)
                                                                                                throws org.apache.axis2.AxisFault

      Invokes `HttpResponseFuture` respond method to send the response back to the client.
      Parameters:
        `requestMsg` - Represent the request message
        `responseMsg` - Represent the corresponding response
      Returns:
        HttpResponseFuture that represent the future results
      Throws:
        `org.apache.axis2.AxisFault`

    - #### getHttpMessageDataStreamer

          public static org.wso2.transport.http.netty.message.HttpMessageDataStreamer getHttpMessageDataStreamer(org.wso2.transport.http.netty.message.HttpCarbonMessage outboundResponse)

      Get the response data streamer that should be used for serializing data.
      Parameters:
        `outboundResponse` - Represents native response
      Returns:
        HttpMessageDataStreamer that should be used for serializing

    - #### serializeDataUsingMessageFormatter

          public static void serializeDataUsingMessageFormatter(org.apache.axis2.context.MessageContext msgContext,
                                                                org.apache.axis2.transport.MessageFormatter messageFormatter,
                                                                java.io.OutputStream outputStream)
                                                         throws org.apache.axis2.AxisFault

      Throws:
        `org.apache.axis2.AxisFault`

    - #### serializeBytes

          public static void serializeBytes(java.io.OutputStream outputStream,
                                            byte[] bytes)
                                     throws org.apache.axis2.AxisFault

      Throws:
        `org.apache.axis2.AxisFault`

    - #### writeEmptyBody

          public static void writeEmptyBody(java.io.OutputStream outputStream)
                                     throws org.apache.axis2.AxisFault

      Throws:
        `org.apache.axis2.AxisFault`

    - #### copyContentFromInboundHttpCarbonMessage

          public static void copyContentFromInboundHttpCarbonMessage(org.wso2.transport.http.netty.message.HttpCarbonMessage inboundMsg,
                                                                     org.wso2.transport.http.netty.message.HttpCarbonMessage outboundResponseMsg)

    - #### closeMessageOutputStreamQuietly

          public static void closeMessageOutputStreamQuietly(java.io.OutputStream messageOutputStream)

    - #### isGETRequest

          public static boolean isGETRequest(org.apache.axis2.context.MessageContext msgCtx)

    - #### isHEADRequest

          public static boolean isHEADRequest(org.apache.axis2.context.MessageContext msgCtx)

    - #### isCONNECTRequest

          public static boolean isCONNECTRequest(org.apache.axis2.context.MessageContext msgCtx)

    - #### isNoEntityBodyRequest

          public static boolean isNoEntityBodyRequest(org.apache.axis2.context.MessageContext msgCtx)

    - #### addTransportHeadersToTransportMessage

          public static void addTransportHeadersToTransportMessage(io.netty.handler.codec.http.HttpHeaders headers,
                                                                   org.apache.axis2.context.MessageContext msgCtx)

    - #### setHostHeader

          public static void setHostHeader(java.lang.String host,
                                           int port,
                                           io.netty.handler.codec.http.HttpHeaders headers,
                                           org.apache.axis2.context.MessageContext msgCtx,
                                           boolean isPreservedHeader)

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