public class HttpUtil extends Object
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(BStruct 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,
BStruct struct)
Check the existence of entity.
|
static void |
checkFunctionValidity(BStruct 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(BStruct struct)
Creates native
Http2PushPromise from PushPromise struct. |
static org.wso2.transport.http.netty.contract.HttpWsConnectorFactory |
createHttpWsConnectionFactory() |
static BStruct |
createSessionStruct(Context context,
Session session) |
static void |
enrichConnectionInfo(BStruct connection,
org.wso2.transport.http.netty.message.HTTPCarbonMessage inboundMsg)
Populate connection information.
|
static void |
enrichOutboundMessage(org.wso2.transport.http.netty.message.HTTPCarbonMessage outboundMsg,
BStruct outboundStruct)
Set headers and properties of request/response struct to the outbound transport message.
|
static void |
enrichServiceEndpointInfo(BStruct serviceEndpoint,
org.wso2.transport.http.netty.message.HTTPCarbonMessage inboundMsg,
HttpResource httpResource)
Populate serviceEndpoint information.
|
static org.wso2.transport.http.netty.message.HTTPCarbonMessage |
getCarbonMsg(BStruct 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 isEntityBodyRequired)
Get the entity from request or response.
|
static org.wso2.transport.http.netty.config.ForwardedExtensionConfig |
getForwardedExtensionConfig(String forwarded) |
static BStruct |
getGenericError(Context context,
String errMsg)
Extract generic error message.
|
static BStruct |
getHttpConnectorError(Context context,
Throwable throwable) |
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(BStruct 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,
BStruct error) |
static void |
injectHeaders(org.wso2.transport.http.netty.message.HTTPCarbonMessage msg,
Map<String,String> headers) |
static boolean |
isEntityDataSourceAvailble(BStruct struct)
Check the existence of the message entity data source.
|
static void |
populateEntityBody(Context context,
BStruct httpMessageStruct,
BStruct entity,
boolean isRequest)
Populate entity with the relevant body content.
|
static void |
populateInboundRequest(BStruct inboundRequestStruct,
BStruct entity,
BStruct mediaType,
org.wso2.transport.http.netty.message.HTTPCarbonMessage inboundRequestMsg,
RequestCacheControlStruct requestCacheControl) |
static void |
populateInboundResponse(BStruct inboundResponse,
BStruct entity,
BStruct mediaType,
ResponseCacheControlStruct responseCacheControl,
org.wso2.transport.http.netty.message.HTTPCarbonMessage inboundResponseMsg)
Populate inbound response with headers and entity.
|
static void |
populatePushPromiseStruct(BStruct pushPromiseStruct,
org.wso2.transport.http.netty.message.Http2PushPromise pushPromise)
Populates the push promise struct from native
Http2PushPromise . |
static void |
prepareOutboundResponse(Context context,
org.wso2.transport.http.netty.message.HTTPCarbonMessage inboundRequestMsg,
org.wso2.transport.http.netty.message.HTTPCarbonMessage outboundResponseMsg,
BStruct 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 |
setEntity(Context context,
boolean isRequest)
Set the given entity to request or response message.
|
static void |
setProperty(Context context,
boolean isRequest) |
public static final int TRUE
public static final int FALSE
public static void setProperty(Context context, boolean isRequest)
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 isEntityBodyRequired)
context
- Ballerina contextisRequest
- boolean representing whether the message is a request or a responseisEntityBodyRequired
- boolean representing whether the entity body is requiredpublic static void populateEntityBody(Context context, BStruct httpMessageStruct, BStruct 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 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, BStruct outboundResponseStruct)
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, BStruct error)
public static org.wso2.transport.http.netty.message.HTTPCarbonMessage createErrorMessage(String payload, int statusCode)
public static BStruct getHttpConnectorError(Context context, Throwable throwable)
public static org.wso2.transport.http.netty.message.HTTPCarbonMessage getCarbonMsg(BStruct struct, org.wso2.transport.http.netty.message.HTTPCarbonMessage defaultMsg)
public static org.wso2.transport.http.netty.message.Http2PushPromise getPushPromise(BStruct 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(BStruct 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(BStruct struct)
Http2PushPromise
from PushPromise struct.struct
- the PushPromise structHttp2PushPromise
public static void addCarbonMsg(BStruct struct, org.wso2.transport.http.netty.message.HTTPCarbonMessage httpCarbonMessage)
public static void populateInboundRequest(BStruct inboundRequestStruct, BStruct entity, BStruct mediaType, org.wso2.transport.http.netty.message.HTTPCarbonMessage inboundRequestMsg, RequestCacheControlStruct requestCacheControl)
public static void enrichConnectionInfo(BStruct connection, org.wso2.transport.http.netty.message.HTTPCarbonMessage inboundMsg)
connection
- Represent the connection structinboundMsg
- Represent carbon message.public static void enrichServiceEndpointInfo(BStruct serviceEndpoint, org.wso2.transport.http.netty.message.HTTPCarbonMessage inboundMsg, HttpResource httpResource)
serviceEndpoint
- Represent the serviceEndpoint structinboundMsg
- Represent carbon message.httpResource
- Represent Http Resource.public static void populateInboundResponse(BStruct inboundResponse, BStruct entity, BStruct mediaType, ResponseCacheControlStruct responseCacheControl, org.wso2.transport.http.netty.message.HTTPCarbonMessage inboundResponseMsg)
inboundResponse
- Ballerina struct to represent responseentity
- Entity of the responsemediaType
- Content type of the responseresponseCacheControl
- 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, BStruct outboundStruct)
outboundMsg
- transport Http carbon message.outboundStruct
- req/resp struct.public static void checkEntityAvailability(Context context, BStruct struct)
context
- ballerina context.struct
- request/response struct.public static boolean isEntityDataSourceAvailble(BStruct 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(BStruct 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 BStruct getGenericError(Context context, String errMsg)
context
- Represent ballerina context.errMsg
- Error message.public static org.wso2.transport.http.netty.contract.HttpWsConnectorFactory createHttpWsConnectionFactory()
public static void checkAndObserveHttpRequest(Context context, org.wso2.transport.http.netty.message.HTTPCarbonMessage message)
Copyright © 2018 WSO2. All rights reserved.