use of org.wso2.transport.http.netty.config.KeepAliveConfig in project ballerina by ballerina-lang.
the class HttpUtil method extractBasicConfig.
@Deprecated
private static void extractBasicConfig(Annotation configInfo, Set<ListenerConfiguration> listenerConfSet) {
AnnAttrValue hostAttrVal = configInfo.getAnnAttrValue(HttpConstants.ANN_CONFIG_ATTR_HOST);
AnnAttrValue portAttrVal = configInfo.getAnnAttrValue(HttpConstants.ANN_CONFIG_ATTR_PORT);
AnnAttrValue keepAliveAttrVal = configInfo.getAnnAttrValue(HttpConstants.ANN_CONFIG_ATTR_KEEP_ALIVE);
AnnAttrValue transferEncoding = configInfo.getAnnAttrValue(HttpConstants.ANN_CONFIG_ATTR_TRANSFER_ENCODING);
AnnAttrValue chunking = configInfo.getAnnAttrValue(HttpConstants.ANN_CONFIG_ATTR_CHUNKING);
AnnAttrValue maxUriLength = configInfo.getAnnAttrValue(HttpConstants.ANN_CONFIG_ATTR_MAXIMUM_URL_LENGTH);
AnnAttrValue maxHeaderSize = configInfo.getAnnAttrValue(HttpConstants.ANN_CONFIG_ATTR_MAXIMUM_HEADER_SIZE);
AnnAttrValue maxEntityBodySize = configInfo.getAnnAttrValue(HttpConstants.ANN_CONFIG_ATTR_MAXIMUM_ENTITY_BODY_SIZE);
AnnAttrValue versionAttrVal = configInfo.getAnnAttrValue(HttpConstants.ANN_CONFIG_ATTR_HTTP_VERSION);
ListenerConfiguration listenerConfiguration = new ListenerConfiguration();
if (portAttrVal != null && portAttrVal.getIntValue() > 0) {
listenerConfiguration.setPort(Math.toIntExact(portAttrVal.getIntValue()));
listenerConfiguration.setScheme(HttpConstants.PROTOCOL_HTTP);
if (hostAttrVal != null && hostAttrVal.getStringValue() != null) {
listenerConfiguration.setHost(hostAttrVal.getStringValue());
} else {
listenerConfiguration.setHost(HttpConstants.HTTP_DEFAULT_HOST);
}
// chunking. Once we start supporting gzip, deflate, etc, we need to parse down the config.
if (transferEncoding != null && !HttpConstants.ANN_CONFIG_ATTR_CHUNKING.equalsIgnoreCase(transferEncoding.getStringValue())) {
throw new BallerinaConnectorException("Unsupported configuration found for Transfer-Encoding : " + transferEncoding.getStringValue());
}
if (chunking != null) {
ChunkConfig chunkConfig = getChunkConfig(chunking.getStringValue());
listenerConfiguration.setChunkConfig(chunkConfig);
} else {
listenerConfiguration.setChunkConfig(ChunkConfig.AUTO);
}
if (keepAliveAttrVal != null) {
KeepAliveConfig keepAliveConfig = getKeepAliveConfig(keepAliveAttrVal.getStringValue());
listenerConfiguration.setKeepAliveConfig(keepAliveConfig);
} else {
listenerConfiguration.setKeepAliveConfig(KeepAliveConfig.AUTO);
}
RequestSizeValidationConfig requestSizeValidationConfig = listenerConfiguration.getRequestSizeValidationConfig();
if (maxUriLength != null) {
if (maxUriLength.getIntValue() > 0) {
requestSizeValidationConfig.setMaxUriLength(Math.toIntExact(maxUriLength.getIntValue()));
} else {
throw new BallerinaConnectorException("Invalid configuration found for maxUriLength : " + maxUriLength.getIntValue());
}
}
if (maxHeaderSize != null) {
if (maxHeaderSize.getIntValue() > 0) {
requestSizeValidationConfig.setMaxHeaderSize(Math.toIntExact(maxHeaderSize.getIntValue()));
} else {
throw new BallerinaConnectorException("Invalid configuration found for maxHeaderSize : " + maxHeaderSize.getIntValue());
}
}
if (maxEntityBodySize != null) {
if (maxEntityBodySize.getIntValue() > 0) {
requestSizeValidationConfig.setMaxEntityBodySize(Math.toIntExact(maxEntityBodySize.getIntValue()));
} else {
throw new BallerinaConnectorException("Invalid configuration found for maxEntityBodySize : " + maxEntityBodySize.getIntValue());
}
}
if (versionAttrVal != null) {
listenerConfiguration.setVersion(versionAttrVal.getStringValue());
}
listenerConfiguration.setId(getListenerInterface(listenerConfiguration.getHost(), listenerConfiguration.getPort()));
listenerConfSet.add(listenerConfiguration);
}
}
Aggregations