public class HttpUtil extends Object
Modifier and Type | Field and Description |
---|---|
static boolean |
FALSE |
static boolean |
TRUE |
Constructor and Description |
---|
HttpUtil() |
Modifier and Type | Method and Description |
---|---|
static String |
addBoundaryIfNotExist(org.wso2.transport.http.netty.message.HTTPCarbonMessage transportMessage,
String contentType)
If the given Content-Type header value doesn't have a boundary parameter value, get a new boundary string and
append it to Content-Type and set it to transport message.
|
static void |
addCarbonMsg(BMap<String,BValue> struct,
org.wso2.transport.http.netty.message.HTTPCarbonMessage httpCarbonMessage) |
static void |
addHTTPSessionAndCorsHeaders(Context context,
org.wso2.transport.http.netty.message.HTTPCarbonMessage requestMsg,
org.wso2.transport.http.netty.message.HTTPCarbonMessage responseMsg) |
static void |
checkAndObserveHttpRequest(Context context,
org.wso2.transport.http.netty.message.HTTPCarbonMessage message) |
static void |
checkEntityAvailability(Context context,
BMap<String,BValue> struct)
Check the existence of entity.
|
static void |
checkFunctionValidity(BMap<String,BValue> connectionStruct,
org.wso2.transport.http.netty.message.HTTPCarbonMessage reqMsg) |
static void |
closeMessageOutputStream(OutputStream messageOutputStream) |
static org.wso2.transport.http.netty.message.HTTPCarbonMessage |
createErrorMessage(String payload,
int statusCode) |
static org.wso2.transport.http.netty.message.HTTPCarbonMessage |
createHttpCarbonMessage(boolean isRequest) |
static org.wso2.transport.http.netty.message.Http2PushPromise |
createHttpPushPromise(BMap<String,BValue> struct)
Creates native
Http2PushPromise from PushPromise struct. |
static org.wso2.transport.http.netty.contract.HttpWsConnectorFactory |
createHttpWsConnectionFactory() |
static BMap<String,BValue> |
createNewEntity(Context context,
BMap<String,BValue> httpMessageStruct)
Set new entity to in/out request/response struct.
|
static BMap<String,BValue> |
createResponseStruct(Context context,
org.wso2.transport.http.netty.message.HTTPCarbonMessage httpCarbonMessage)
Creates InResponse using the native
HTTPCarbonMessage . |
static BMap<String,BValue> |
createSessionStruct(Context context,
Session session) |
static void |
enrichConnectionInfo(BMap<String,BValue> connection,
org.wso2.transport.http.netty.message.HTTPCarbonMessage inboundMsg,
Struct config)
Populate connection information.
|
static void |
enrichOutboundMessage(org.wso2.transport.http.netty.message.HTTPCarbonMessage outboundMsg,
BMap<String,BValue> outboundStruct)
Set headers and properties of request/response struct to the outbound transport message.
|
static void |
enrichServiceEndpointInfo(BMap<String,BValue> serviceEndpoint,
org.wso2.transport.http.netty.message.HTTPCarbonMessage inboundMsg,
HttpResource httpResource,
Struct config)
Populate serviceEndpoint information.
|
static BMap<String,BValue> |
extractEntity(BMap<String,BValue> httpMessageStruct) |
static org.wso2.transport.http.netty.message.HTTPCarbonMessage |
getCarbonMsg(BMap<String,BValue> struct,
org.wso2.transport.http.netty.message.HTTPCarbonMessage defaultMsg) |
static org.wso2.transport.http.netty.config.ChunkConfig |
getChunkConfig(String chunkConfig) |
static String |
getContentTypeFromTransportMessage(org.wso2.transport.http.netty.message.HTTPCarbonMessage transportMessage) |
static BValue[] |
getEntity(Context context,
boolean isRequest,
boolean entityBodyRequired)
Get the entity from request or response.
|
static BMap<String,BValue> |
getError(Context context,
String errMsg)
Get error struct.
|
static BMap<String,BValue> |
getError(Context context,
Throwable throwable)
Get error struct from throwable.
|
static org.wso2.transport.http.netty.config.ForwardedExtensionConfig |
getForwardedExtensionConfig(String forwarded) |
static org.wso2.transport.http.netty.config.KeepAliveConfig |
getKeepAliveConfig(String keepAliveConfig) |
static String |
getListenerInterface(String host,
int port) |
static BValue[] |
getProperty(Context context,
boolean isRequest) |
static org.wso2.transport.http.netty.message.Http2PushPromise |
getPushPromise(BMap<String,BValue> pushPromiseStruct,
org.wso2.transport.http.netty.message.Http2PushPromise defaultPushPromise)
Gets the
Http2PushPromise represented by the PushPromise struct. |
static Annotation |
getResourceConfigAnnotation(Resource resource,
String pkgPath) |
static Annotation |
getServiceConfigAnnotation(Service service,
String pkgPath) |
static Annotation |
getServiceConfigStruct(Service service,
String pkgPath) |
static String |
getSessionID(String cookieHeader) |
static void |
handleFailure(org.wso2.transport.http.netty.message.HTTPCarbonMessage requestMessage,
BallerinaConnectorException ex) |
static void |
handleFailure(org.wso2.transport.http.netty.message.HTTPCarbonMessage requestMessage,
BMap<String,BValue> error) |
static void |
injectHeaders(org.wso2.transport.http.netty.message.HTTPCarbonMessage msg,
Map<String,String> headers) |
static boolean |
isEntityDataSourceAvailable(BMap<String,BValue> struct)
Check the existence of the message entity data source.
|
static boolean |
isRequestStruct(BMap<String,BValue> struct) |
static void |
populateEntityBody(Context context,
BMap<String,BValue> httpMessageStruct,
BMap<String,BValue> entity,
boolean isRequest)
Populate entity with the relevant body content.
|
static void |
populateInboundRequest(BMap<String,BValue> inboundRequestStruct,
BMap<String,BValue> entity,
BMap<String,BValue> mediaType,
org.wso2.transport.http.netty.message.HTTPCarbonMessage inboundRequestMsg,
ProgramFile programFile) |
static void |
populateInboundResponse(BMap<String,BValue> inboundResponse,
BMap<String,BValue> entity,
BMap<String,BValue> mediaType,
ProgramFile programFile,
org.wso2.transport.http.netty.message.HTTPCarbonMessage inboundResponseMsg)
Populate inbound response with headers and entity.
|
static void |
populatePushPromiseStruct(BMap<String,BValue> pushPromiseStruct,
org.wso2.transport.http.netty.message.Http2PushPromise pushPromise)
Populates the push promise struct from native
Http2PushPromise . |
static void |
populateSSLConfiguration(org.wso2.transport.http.netty.config.SslConfiguration sslConfiguration,
Struct secureSocket) |
static void |
prepareOutboundResponse(Context context,
org.wso2.transport.http.netty.message.HTTPCarbonMessage inboundRequestMsg,
org.wso2.transport.http.netty.message.HTTPCarbonMessage outboundResponseMsg,
BMap<String,BValue> outboundResponseStruct) |
static org.wso2.transport.http.netty.contract.HttpResponseFuture |
pushPromise(org.wso2.transport.http.netty.message.HTTPCarbonMessage requestMsg,
org.wso2.transport.http.netty.message.Http2PushPromise pushPromise)
Sends an HTTP/2 Push Promise message back to the client.
|
static org.wso2.transport.http.netty.contract.HttpResponseFuture |
pushResponse(org.wso2.transport.http.netty.message.HTTPCarbonMessage requestMsg,
org.wso2.transport.http.netty.message.HTTPCarbonMessage pushResponse,
org.wso2.transport.http.netty.message.Http2PushPromise pushPromise)
Sends an HTTP/2 Server Push message back to the client.
|
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) |
static void |
serverConnectionStructCheck(org.wso2.transport.http.netty.message.HTTPCarbonMessage reqMsg) |
static void |
setDefaultTrustStore(org.wso2.transport.http.netty.config.SslConfiguration sslConfiguration) |
static void |
setEntity(Context context,
boolean isRequest)
Set the given entity to request or response message.
|
static void |
setProperty(Context context,
boolean isRequest) |
public static final boolean TRUE
public static final boolean FALSE
public static void setProperty(Context context, boolean isRequest)
public static BMap<String,BValue> createNewEntity(Context context, BMap<String,BValue> httpMessageStruct)
context
- ballerina context.httpMessageStruct
- request/response struct.public static void setEntity(Context context, boolean isRequest)
context
- Ballerina contextisRequest
- boolean representing whether the message is a request or a responsepublic static BValue[] getEntity(Context context, boolean isRequest, boolean entityBodyRequired)
context
- Ballerina contextisRequest
- boolean representing whether the message is a request or a responseentityBodyRequired
- boolean representing whether the entity body is requiredpublic static void populateEntityBody(Context context, BMap<String,BValue> httpMessageStruct, BMap<String,BValue> entity, boolean isRequest)
context
- Represent ballerina contexthttpMessageStruct
- Represent ballerina request/responseentity
- Represent an entityisRequest
- boolean representing whether the message is a request or a responsepublic static BMap<String,BValue> extractEntity(BMap<String,BValue> httpMessageStruct)
public static void closeMessageOutputStream(OutputStream messageOutputStream)
public static void prepareOutboundResponse(Context context, org.wso2.transport.http.netty.message.HTTPCarbonMessage inboundRequestMsg, org.wso2.transport.http.netty.message.HTTPCarbonMessage outboundResponseMsg, BMap<String,BValue> outboundResponseStruct)
public static BMap<String,BValue> createSessionStruct(Context context, Session session)
public static void addHTTPSessionAndCorsHeaders(Context context, org.wso2.transport.http.netty.message.HTTPCarbonMessage requestMsg, org.wso2.transport.http.netty.message.HTTPCarbonMessage responseMsg)
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)
public static org.wso2.transport.http.netty.contract.HttpResponseFuture pushResponse(org.wso2.transport.http.netty.message.HTTPCarbonMessage requestMsg, org.wso2.transport.http.netty.message.HTTPCarbonMessage pushResponse, org.wso2.transport.http.netty.message.Http2PushPromise pushPromise)
requestMsg
- the request message associated to the server push responsepushResponse
- the server push messagepushPromise
- the push promise associated with the server pushpublic static org.wso2.transport.http.netty.contract.HttpResponseFuture pushPromise(org.wso2.transport.http.netty.message.HTTPCarbonMessage requestMsg, org.wso2.transport.http.netty.message.Http2PushPromise pushPromise)
requestMsg
- the request message associated to the push promisepushPromise
- the push promise messagepublic static void handleFailure(org.wso2.transport.http.netty.message.HTTPCarbonMessage requestMessage, BallerinaConnectorException ex)
public static void handleFailure(org.wso2.transport.http.netty.message.HTTPCarbonMessage requestMessage, BMap<String,BValue> error)
public static org.wso2.transport.http.netty.message.HTTPCarbonMessage createErrorMessage(String payload, int statusCode)
public static BMap<String,BValue> getError(Context context, String errMsg)
context
- Represent ballerina contexterrMsg
- Error messagepublic static BMap<String,BValue> getError(Context context, Throwable throwable)
context
- Represent ballerina contextthrowable
- Throwable representing the error.public static org.wso2.transport.http.netty.message.HTTPCarbonMessage getCarbonMsg(BMap<String,BValue> struct, org.wso2.transport.http.netty.message.HTTPCarbonMessage defaultMsg)
public static org.wso2.transport.http.netty.message.Http2PushPromise getPushPromise(BMap<String,BValue> pushPromiseStruct, org.wso2.transport.http.netty.message.Http2PushPromise defaultPushPromise)
Http2PushPromise
represented by the PushPromise struct.pushPromiseStruct
- the push promise structdefaultPushPromise
- the Http2PushPromise to use if the struct does not have native data of a push promiseHttp2PushPromise
represented by the PushPromise structpublic static void populatePushPromiseStruct(BMap<String,BValue> pushPromiseStruct, org.wso2.transport.http.netty.message.Http2PushPromise pushPromise)
Http2PushPromise
.pushPromiseStruct
- the push promise structpushPromise
- the native Http2PushPromisepublic static org.wso2.transport.http.netty.message.Http2PushPromise createHttpPushPromise(BMap<String,BValue> struct)
Http2PushPromise
from PushPromise struct.struct
- the PushPromise structHttp2PushPromise
public static void addCarbonMsg(BMap<String,BValue> struct, org.wso2.transport.http.netty.message.HTTPCarbonMessage httpCarbonMessage)
public static void populateInboundRequest(BMap<String,BValue> inboundRequestStruct, BMap<String,BValue> entity, BMap<String,BValue> mediaType, org.wso2.transport.http.netty.message.HTTPCarbonMessage inboundRequestMsg, ProgramFile programFile)
public static void enrichConnectionInfo(BMap<String,BValue> connection, org.wso2.transport.http.netty.message.HTTPCarbonMessage inboundMsg, Struct config)
connection
- Represent the connection structinboundMsg
- Represent carbon message.public static void enrichServiceEndpointInfo(BMap<String,BValue> serviceEndpoint, org.wso2.transport.http.netty.message.HTTPCarbonMessage inboundMsg, HttpResource httpResource, Struct config)
serviceEndpoint
- Represent the serviceEndpoint structinboundMsg
- Represent carbon message.httpResource
- Represent Http Resource.public static void populateInboundResponse(BMap<String,BValue> inboundResponse, BMap<String,BValue> entity, BMap<String,BValue> mediaType, ProgramFile programFile, org.wso2.transport.http.netty.message.HTTPCarbonMessage inboundResponseMsg)
inboundResponse
- Ballerina struct to represent responseentity
- Entity of the responsemediaType
- Content type of the responseprogramFile
- Cache control struct which holds the cache control directives related to the
responseinboundResponseMsg
- Represent carbon message.public static void enrichOutboundMessage(org.wso2.transport.http.netty.message.HTTPCarbonMessage outboundMsg, BMap<String,BValue> outboundStruct)
outboundMsg
- transport Http carbon message.outboundStruct
- req/resp struct.public static void checkEntityAvailability(Context context, BMap<String,BValue> struct)
context
- ballerina context.struct
- request/response struct.public static boolean isEntityDataSourceAvailable(BMap<String,BValue> struct)
struct
- request/response struct.public static org.wso2.transport.http.netty.config.ChunkConfig getChunkConfig(String chunkConfig)
public static org.wso2.transport.http.netty.config.KeepAliveConfig getKeepAliveConfig(String keepAliveConfig)
public static org.wso2.transport.http.netty.config.ForwardedExtensionConfig getForwardedExtensionConfig(String forwarded)
public static org.wso2.transport.http.netty.message.HTTPCarbonMessage createHttpCarbonMessage(boolean isRequest)
public static void checkFunctionValidity(BMap<String,BValue> connectionStruct, org.wso2.transport.http.netty.message.HTTPCarbonMessage reqMsg)
public static void serverConnectionStructCheck(org.wso2.transport.http.netty.message.HTTPCarbonMessage reqMsg)
public static Annotation getServiceConfigAnnotation(Service service, String pkgPath)
public static Annotation getServiceConfigStruct(Service service, String pkgPath)
public static Annotation getResourceConfigAnnotation(Resource resource, String pkgPath)
public static String getContentTypeFromTransportMessage(org.wso2.transport.http.netty.message.HTTPCarbonMessage transportMessage)
public static String addBoundaryIfNotExist(org.wso2.transport.http.netty.message.HTTPCarbonMessage transportMessage, String contentType)
transportMessage
- Represent transport messagecontentType
- Represent the Content-Type header valuepublic static org.wso2.transport.http.netty.contract.HttpWsConnectorFactory createHttpWsConnectionFactory()
public static void checkAndObserveHttpRequest(Context context, org.wso2.transport.http.netty.message.HTTPCarbonMessage message)
public static void injectHeaders(org.wso2.transport.http.netty.message.HTTPCarbonMessage msg, Map<String,String> headers)
public static BMap<String,BValue> createResponseStruct(Context context, org.wso2.transport.http.netty.message.HTTPCarbonMessage httpCarbonMessage)
HTTPCarbonMessage
.context
- ballerina contexthttpCarbonMessage
- the HTTPCarbonMessagepublic static void populateSSLConfiguration(org.wso2.transport.http.netty.config.SslConfiguration sslConfiguration, Struct secureSocket)
public static void setDefaultTrustStore(org.wso2.transport.http.netty.config.SslConfiguration sslConfiguration)
Copyright © 2018 WSO2. All rights reserved.