本文整理汇总了Java中org.apache.coyote.http11.AbstractHttp11Protocol类的典型用法代码示例。如果您正苦于以下问题:Java AbstractHttp11Protocol类的具体用法?Java AbstractHttp11Protocol怎么用?Java AbstractHttp11Protocol使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AbstractHttp11Protocol类属于org.apache.coyote.http11包,在下文中一共展示了AbstractHttp11Protocol类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: servletContainerCustomizer
import org.apache.coyote.http11.AbstractHttp11Protocol; //导入依赖的package包/类
@Bean
public EmbeddedServletContainerCustomizer servletContainerCustomizer()
{
return new EmbeddedServletContainerCustomizer()
{
@Override
public void customize(final ConfigurableEmbeddedServletContainer servletContainer)
{
final TomcatEmbeddedServletContainerFactory tomcatContainerFactory = (TomcatEmbeddedServletContainerFactory)servletContainer;
tomcatContainerFactory.addConnectorCustomizers(new TomcatConnectorCustomizer()
{
@Override
public void customize(final Connector connector)
{
final AbstractHttp11Protocol<?> httpProtocol = (AbstractHttp11Protocol<?>)connector.getProtocolHandler();
httpProtocol.setCompression("on");
httpProtocol.setCompressionMinSize(256);
final String mimeTypes = httpProtocol.getCompressibleMimeType();
final String mimeTypesWithJson = mimeTypes + "," + MediaType.APPLICATION_JSON_VALUE + ",application/javascript";
httpProtocol.setCompressibleMimeType(mimeTypesWithJson);
}
});
}
};
}
示例2: customizeCompression
import org.apache.coyote.http11.AbstractHttp11Protocol; //导入依赖的package包/类
private void customizeCompression(Connector connector) {
ProtocolHandler handler = connector.getProtocolHandler();
if (handler instanceof AbstractHttp11Protocol) {
AbstractHttp11Protocol<?> protocol = (AbstractHttp11Protocol<?>) handler;
Compression compression = getCompression();
protocol.setCompression("on");
protocol.setCompressionMinSize(compression.getMinResponseSize());
protocol.setCompressableMimeType(
StringUtils.arrayToCommaDelimitedString(compression.getMimeTypes()));
if (getCompression().getExcludedUserAgents() != null) {
protocol.setNoCompressionUserAgents(
StringUtils.arrayToCommaDelimitedString(
getCompression().getExcludedUserAgents()));
}
}
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:17,代码来源:TomcatEmbeddedServletContainerFactory.java
示例3: customizeMaxHttpHeaderSize
import org.apache.coyote.http11.AbstractHttp11Protocol; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
private void customizeMaxHttpHeaderSize(
TomcatEmbeddedServletContainerFactory factory,
final int maxHttpHeaderSize) {
factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
@Override
public void customize(Connector connector) {
ProtocolHandler handler = connector.getProtocolHandler();
if (handler instanceof AbstractHttp11Protocol) {
AbstractHttp11Protocol protocol = (AbstractHttp11Protocol) handler;
protocol.setMaxHttpHeaderSize(maxHttpHeaderSize);
}
}
});
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:18,代码来源:ServerProperties.java
示例4: customizeCompression
import org.apache.coyote.http11.AbstractHttp11Protocol; //导入依赖的package包/类
private void customizeCompression(Connector connector) {
ProtocolHandler handler = connector.getProtocolHandler();
if (handler instanceof AbstractHttp11Protocol) {
AbstractHttp11Protocol<?> protocol = (AbstractHttp11Protocol<?>) handler;
Compression compression = getCompression();
protocol.setCompression("on");
protocol.setCompressionMinSize(compression.getMinResponseSize());
protocol.setCompressableMimeTypes(
StringUtils.arrayToCommaDelimitedString(compression.getMimeTypes()));
if (getCompression().getExcludedUserAgents() != null) {
protocol.setNoCompressionUserAgents(
StringUtils.arrayToCommaDelimitedString(
getCompression().getExcludedUserAgents()));
}
}
}
示例5: servletContainerCustomizer
import org.apache.coyote.http11.AbstractHttp11Protocol; //导入依赖的package包/类
@Bean
public EmbeddedServletContainerCustomizer servletContainerCustomizer() {
return servletContainer -> {
addMimeMappingsForFonts(servletContainer);
TomcatEmbeddedServletContainerFactory container = (TomcatEmbeddedServletContainerFactory) servletContainer;
container.setRegisterJspServlet(false);
container.addContextCustomizers(customizer -> customizer.addWelcomeFile("index.html"));
container.addConnectorCustomizers(
connector -> {
AbstractHttp11Protocol httpProtocol = (AbstractHttp11Protocol) connector.getProtocolHandler();
httpProtocol.setCompression("on");
httpProtocol.setCompressionMinSize(256);
httpProtocol.setCompressableMimeTypes(COMPRESSIBLE_MEDIA_TYPES);
}
);
};
}
示例6: customizeMaxHttpHeaderSize
import org.apache.coyote.http11.AbstractHttp11Protocol; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
private void customizeMaxHttpHeaderSize(
TomcatEmbeddedServletContainerFactory factory) {
factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
@Override
public void customize(Connector connector) {
ProtocolHandler handler = connector.getProtocolHandler();
if (handler instanceof AbstractHttp11Protocol) {
AbstractHttp11Protocol protocol = (AbstractHttp11Protocol) handler;
protocol.setMaxHttpHeaderSize(Tomcat.this.maxHttpHeaderSize);
}
}
});
}
示例7: servletContainerCustomizer
import org.apache.coyote.http11.AbstractHttp11Protocol; //导入依赖的package包/类
@Bean
public EmbeddedServletContainerCustomizer servletContainerCustomizer(){
return configurableEmbeddedServletContainer ->
((TomcatEmbeddedServletContainerFactory) configurableEmbeddedServletContainer).addConnectorCustomizers(
new TomcatConnectorCustomizer() {
@Override
public void customize(Connector connector) {
AbstractHttp11Protocol httpProtocol = (AbstractHttp11Protocol) connector.getProtocolHandler();
httpProtocol.setCompression("on");
httpProtocol.setCompressionMinSize(256);
String mimeTypes = httpProtocol.getCompressableMimeTypes();
String mimeTypesWithJson = mimeTypes + "," + MediaType.APPLICATION_JSON_VALUE;
httpProtocol.setCompressableMimeTypes(mimeTypesWithJson);
}
}
);
}
示例8: servletContainerCustomizer
import org.apache.coyote.http11.AbstractHttp11Protocol; //导入依赖的package包/类
/**
* Configure embedded tomcat so that is use gzip for various resources.
*/
@Bean
public EmbeddedServletContainerCustomizer servletContainerCustomizer()
{
return new EmbeddedServletContainerCustomizer()
{
@Override
public void customize(final ConfigurableEmbeddedServletContainer servletContainer)
{
final TomcatEmbeddedServletContainerFactory tomcatContainerFactory = (TomcatEmbeddedServletContainerFactory)servletContainer;
tomcatContainerFactory.addConnectorCustomizers(new TomcatConnectorCustomizer()
{
@Override
public void customize(final Connector connector)
{
final AbstractHttp11Protocol<?> httpProtocol = (AbstractHttp11Protocol<?>)connector.getProtocolHandler();
httpProtocol.setCompression("on");
httpProtocol.setCompressionMinSize(256);
final StringBuffer mimeTypes = new StringBuffer(httpProtocol.getCompressableMimeType());
if(!mimeTypes.toString().contains("MediaType.APPLICATION_JSON_VALUE"))
{
mimeTypes.append(","+MediaType.APPLICATION_JSON_VALUE);
}
if(!mimeTypes.toString().contains("application/javascript"))
{
mimeTypes.append(",application/javascript");
}
httpProtocol.setCompressableMimeType(mimeTypes.toString());
}
});
}
};
}
示例9: servletContainerCustomizer
import org.apache.coyote.http11.AbstractHttp11Protocol; //导入依赖的package包/类
@Bean
public EmbeddedServletContainerCustomizer servletContainerCustomizer() {
return servletContainer -> ((TomcatEmbeddedServletContainerFactory) servletContainer).addConnectorCustomizers(
connector -> {
AbstractHttp11Protocol httpProtocol = (AbstractHttp11Protocol) connector.getProtocolHandler();
httpProtocol.setCompression("on");
httpProtocol.setCompressionMinSize(256);
String mimeTypes = httpProtocol.getCompressableMimeTypes();
mimeTypes += "," + MediaType.APPLICATION_JSON_VALUE;
mimeTypes += "," + "text/css";
mimeTypes += "," + "application/javascript";
httpProtocol.setCompressableMimeTypes(mimeTypes);
}
);
}
示例10: servletContainerCustomizer
import org.apache.coyote.http11.AbstractHttp11Protocol; //导入依赖的package包/类
@Bean
EmbeddedServletContainerCustomizer servletContainerCustomizer() {
return servletContainer -> ((TomcatEmbeddedServletContainerFactory) servletContainer)
.addConnectorCustomizers(connector -> {
AbstractHttp11Protocol<?> httpProtocol = (AbstractHttp11Protocol<?>) connector.getProtocolHandler();
httpProtocol.setCompression("on");
httpProtocol.setCompressionMinSize(256);
String mimeTypes = httpProtocol.getCompressableMimeTypes();
String mimeTypesWithJson = mimeTypes + "," + MediaType.APPLICATION_JSON_VALUE + ",application/javascript";
httpProtocol.setCompressableMimeTypes(mimeTypesWithJson);
});
}
示例11: createConnector
import org.apache.coyote.http11.AbstractHttp11Protocol; //导入依赖的package包/类
@Test
public void createConnector() {
final AtomicReference<Connector> connector = new AtomicReference<>();
try {
new Container(new Configuration()
.property("connector.xpoweredBy", "true")
.property("connector.attributes.compression", "true")
.property("connector.attributes.maxHeaderCount", "2016")) {
@Override
protected Connector createConnector() {
final Connector connector1 = super.createConnector();
connector.set(connector1);
throw new RuntimeException("end");
}
};
fail("we throw an exception to prevent startup");
} catch (final Exception re) {
assertEquals(re.getMessage(), "java.lang.RuntimeException: end", re.getMessage());
final Connector c = connector.get();
assertNotNull(c);
assertTrue(c.getXpoweredBy());
assertEquals(2016, AbstractHttp11Protocol.class.cast(c.getProtocolHandler()).getMaxHeaderCount());
assertEquals("true", AbstractHttp11Protocol.class.cast(c.getProtocolHandler()).getCompression());
}
}
示例12: servletContainerCustomizer
import org.apache.coyote.http11.AbstractHttp11Protocol; //导入依赖的package包/类
@Bean
public EmbeddedServletContainerCustomizer servletContainerCustomizer() {
return (factory) -> ((TomcatEmbeddedServletContainerFactory) factory)
.addConnectorCustomizers((connector) -> ((AbstractHttp11Protocol<?>) connector.getProtocolHandler())
.setUseServerCipherSuitesOrder(Boolean.toString(true)));
}
示例13: initialize
import org.apache.coyote.http11.AbstractHttp11Protocol; //导入依赖的package包/类
public void initialize() {
try {
JFishTomcat tomcat = new JFishTomcat();
if(serverConfig.getTomcatContextClassName()!=null){
tomcat.setContextClass((Class<StandardContext>)ReflectUtils.loadClass(serverConfig.getTomcatContextClassName(), true));
}
int port = serverConfig.getPort();
tomcat.setPort(port);
// tomcat.setBaseDir(webConfig.getServerBaseDir());
String baseDir = null;
if(!Utils.isBlank(serverConfig.getServerBaseDir())){
baseDir = serverConfig.getServerBaseDir();
}else{
baseDir = System.getProperty("java.io.tmpdir");
logger.info("set serverBaseDir as java.io.tmpdir : {} ", baseDir);
}
tomcat.setBaseDir(baseDir);
// This magic line makes Tomcat look for WAR files in catalinaHome/webapps
// and automatically deploy them
// tomcat.getHost().addLifecycleListener(new HostConfig());
appBaseFile = new File(baseDir+"/tomcat.webapps."+this.serverConfig.getPort());
if(!appBaseFile.exists()){
appBaseFile.mkdirs();
}
appBaseFile.deleteOnExit();
tomcat.getHost().setAppBase(appBaseFile.getAbsolutePath());
Connector connector = tomcat.getConnector();
connector.setURIEncoding("UTF-8");
connector.setRedirectPort(serverConfig.getRedirectPort());
connector.setMaxPostSize(serverConfig.getMaxPostSize());
ProtocolHandler protocol = connector.getProtocolHandler();
if(protocol instanceof AbstractHttp11Protocol){
/*****
* <Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8181" compression="500"
compressableMimeType="text/html,text/xml,text/plain,application/octet-stream" />
*/
AbstractHttp11Protocol<?> hp = (AbstractHttp11Protocol<?>) protocol;
hp.setCompression("on");
hp.setCompressableMimeTypes("text/html,text/xml,text/plain,application/octet-stream");
}
StandardServer server = (StandardServer) tomcat.getServer();
AprLifecycleListener listener = new AprLifecycleListener();
server.addLifecycleListener(listener);
/*tomcat.addUser("adminuser", "adminuser");
tomcat.addRole("adminuser", "admin");
tomcat.addRole("adminuser", "admin");*/
this.tomcat = tomcat;
} catch (Exception e) {
throw new RuntimeException("web server initialize error , check it. " + e.getMessage(), e);
}
/*Runtime.getRuntime().addShutdownHook(new Thread(){
@Override
public void run() {
appBaseFile.delete();
}
});*/
}