当前位置: 首页>>代码示例>>Java>>正文


Java HttpScheme类代码示例

本文整理汇总了Java中org.eclipse.jetty.http.HttpScheme的典型用法代码示例。如果您正苦于以下问题:Java HttpScheme类的具体用法?Java HttpScheme怎么用?Java HttpScheme使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


HttpScheme类属于org.eclipse.jetty.http包,在下文中一共展示了HttpScheme类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: verifyConfiguration

import org.eclipse.jetty.http.HttpScheme; //导入依赖的package包/类
/**
 * Verifies all the needed bits are present in Jetty XML configuration (as HTTPS must be enabled by users).
 */
private void verifyConfiguration(final HttpScheme httpScheme) {
  try {
    if (HttpScheme.HTTP == httpScheme) {
      bean(HTTP_CONFIG_ID, HttpConfiguration.class);
      bean(HTTP_CONNECTOR_ID, ServerConnector.class);
    }
    else if (HttpScheme.HTTPS == httpScheme) {
      bean(SSL_CONTEXT_FACTORY_ID, SslContextFactory.class);
      bean(HTTPS_CONFIG_ID, HttpConfiguration.class);
      bean(HTTPS_CONNECTOR_ID, ServerConnector.class);
    }
    else {
      throw new UnsupportedHttpSchemeException(httpScheme);
    }
  }
  catch (IllegalStateException e) {
    throw new IllegalStateException("Jetty HTTPS is not enabled in Nexus", e);
  }
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:23,代码来源:ConnectorManager.java

示例2: validate

import org.eclipse.jetty.http.HttpScheme; //导入依赖的package包/类
private void validate(final ConnectorConfiguration connectorConfiguration) {
  // connector is not already added
  checkArgument(!managedConfigurations.containsKey(connectorConfiguration));

  // schema is not null and is available
  final HttpScheme httpScheme = connectorConfiguration.getScheme();
  checkNotNull(httpScheme);
  if (!availableSchemes().contains(httpScheme)) {
    throw new UnsupportedHttpSchemeException(httpScheme);
  }

  // port is ok and free
  final int port = connectorConfiguration.getPort();
  checkArgument(port > 0);
  checkArgument(port < 65536);
  checkArgument(!unavailablePorts().contains(port));
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:18,代码来源:ConnectorRegistrarImpl.java

示例3: get

import org.eclipse.jetty.http.HttpScheme; //导入依赖的package包/类
@Override
public ServerConnector get(Server server) {
  HttpConfiguration configuration = new HttpConfiguration(defaultConfig);
  configuration.setSecurePort(configurator.getPort());
  configuration.setSecureScheme(HttpScheme.HTTPS.asString());

  final ServerConnector connector = new ServerConnector(server, new HttpConnectionFactory(configuration));
  connector.setPort(configurator.getPort());
  connector.setHost(configurator.getHost());

  return connector;
}
 
开发者ID:sorskod,项目名称:webserver,代码行数:13,代码来源:HTTPSConnectorFactory.java

示例4: defaultHttpConfiguration

import org.eclipse.jetty.http.HttpScheme; //导入依赖的package包/类
/**
 * Returns the OOTB defined configuration for given HTTP scheme.
 */
private HttpConfiguration defaultHttpConfiguration(final HttpScheme httpScheme) {
  if (HttpScheme.HTTP == httpScheme) {
    return bean(HTTP_CONFIG_ID, HttpConfiguration.class);
  }
  else if (HttpScheme.HTTPS == httpScheme) {
    return bean(HTTPS_CONFIG_ID, HttpConfiguration.class);
  }
  else {
    throw new UnsupportedHttpSchemeException(httpScheme);
  }
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:15,代码来源:ConnectorManager.java

示例5: defaultConnector

import org.eclipse.jetty.http.HttpScheme; //导入依赖的package包/类
/**
 * Returns the OOTB defined connector for given HTTP scheme.
 */
private ServerConnector defaultConnector(final HttpScheme httpScheme) {
  if (HttpScheme.HTTP == httpScheme) {
    return bean(HTTP_CONNECTOR_ID, ServerConnector.class);
  }
  else if (HttpScheme.HTTPS == httpScheme) {
    return bean(HTTPS_CONNECTOR_ID, ServerConnector.class);
  }
  else {
    throw new UnsupportedHttpSchemeException(httpScheme);
  }
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:15,代码来源:ConnectorManager.java

示例6: availableSchemes

import org.eclipse.jetty.http.HttpScheme; //导入依赖的package包/类
@Override
public List<HttpScheme> availableSchemes() {
  final List<HttpScheme> result = new ArrayList<>();
  for (ConnectorConfiguration defaultConnector : serverConfiguration.defaultConnectors()) {
    result.add(defaultConnector.getScheme());
  }
  return result;
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:9,代码来源:ConnectorRegistrarImpl.java

示例7: setSchemeAndPort

import org.eclipse.jetty.http.HttpScheme; //导入依赖的package包/类
/**
 * Checks if the request was made over HTTPS. If so it modifies the request so that
 * {@code HttpServletRequest#isSecure()} returns true, {@code HttpServletRequest#getScheme()}
 * returns "https", and {@code HttpServletRequest#getServerPort()} returns 443. Otherwise it sets
 * the scheme to "http" and port to 80.
 *
 * @param request The request to modify.
 */
private void setSchemeAndPort(Request request) {
  String https = request.getHeader(VmApiProxyEnvironment.HTTPS_HEADER);
  String proto = request.getHeader(VmApiProxyEnvironment.X_FORWARDED_PROTO_HEADER);
  if ("on".equals(https) || "https".equals(proto)) {
    request.setSecure(true);
    request.setScheme(HttpScheme.HTTPS.toString());
    request.setAuthority(request.getServerName(), 443);
  } else {
    request.setSecure(false);
    request.setScheme(HttpScheme.HTTP.toString());
    request.setAuthority(request.getServerName(), defaultEnvironment.getServerPort());
  }
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-java-vm-runtime,代码行数:22,代码来源:VmRuntimeWebAppContext.java

示例8: prepare

import org.eclipse.jetty.http.HttpScheme; //导入依赖的package包/类
/**
 * A fully configured Jetty Server instance
 */
public void prepare() throws Exception {

    // === jetty.xml ===
    // Setup Threadpool
    QueuedThreadPool threadPool = new QueuedThreadPool();
    threadPool.setMinThreads(MIN_THREADS);
    threadPool.setMaxThreads(MAX_THREADS);

    // Server
    server = new Server(threadPool);

    // Scheduler
    server.addBean(new ScheduledExecutorScheduler());

    // HTTP Configuration
    HttpConfiguration httpConfig = new HttpConfiguration();
    httpConfig.setSecureScheme(HttpScheme.HTTPS.asString());
    httpConfig.setSecurePort(CONFIG.getJetty().getHttpsPort());
    httpConfig.setOutputBufferSize(32768);
    httpConfig.setRequestHeaderSize(8192);
    httpConfig.setResponseHeaderSize(8192);
    httpConfig.setSendServerVersion(false);
    httpConfig.setSendDateHeader(false);
    httpConfig.setSendXPoweredBy(false);

    // Extra options
    server.setDumpAfterStart(false);
    server.setDumpBeforeStop(false);
    server.setStopAtShutdown(true);
    server.setStopTimeout(STOP_TIMEOUT);

    if (CONFIG.getJetty().isHttpEnabled()) {
        server.addConnector(httpConnector(httpConfig));
    }

    if (CONFIG.getJetty().isHttpsEnabled()) {
        server.addConnector(httpsConnector(httpConfig));
    }

    SteveAppContext steveAppContext = new SteveAppContext();
    server.setHandler(steveAppContext.getHandlers());
}
 
开发者ID:RWTH-i5-IDSG,项目名称:steve-plugsurfing,代码行数:46,代码来源:JettyServer.java

示例9: addConnector

import org.eclipse.jetty.http.HttpScheme; //导入依赖的package包/类
/**
 * Adds and starts connector to Jetty based on passed in configuration.
 */
public ServerConnector addConnector(final ConnectorConfiguration connectorConfiguration)
{
  final HttpScheme httpScheme = connectorConfiguration.getScheme();
  verifyConfiguration(httpScheme);

  final HttpConfiguration httpConfiguration =
      connectorConfiguration.customize(defaultHttpConfiguration(httpScheme));
  final ServerConnector connectorPrototype =
      defaultConnector(httpScheme);
  final ServerConnector serverConnector;
  if (HttpScheme.HTTP == httpScheme) {
    serverConnector = new ServerConnector(
        server,
        connectorPrototype.getAcceptors(),
        connectorPrototype.getSelectorManager().getSelectorCount(),
        new InstrumentedConnectionFactory(
            new HttpConnectionFactory(httpConfiguration)
        )
    );
  }
  else if (HttpScheme.HTTPS == httpScheme) {
    final SslContextFactory sslContextFactory = bean(SSL_CONTEXT_FACTORY_ID, SslContextFactory.class);
    serverConnector = new ServerConnector(
        server,
        connectorPrototype.getAcceptors(),
        connectorPrototype.getSelectorManager().getSelectorCount(),
        new InstrumentedConnectionFactory(
            new SslConnectionFactory(sslContextFactory, "http/1.1")
        ),
        new HttpConnectionFactory(httpConfiguration)
    );
  }
  else {
    throw new UnsupportedHttpSchemeException(httpScheme);
  }
  serverConnector.setHost(connectorPrototype.getHost());
  serverConnector.setPort(connectorConfiguration.getPort());
  serverConnector.setIdleTimeout(connectorPrototype.getIdleTimeout());
  serverConnector.setSoLingerTime(connectorPrototype.getSoLingerTime());
  serverConnector.setAcceptorPriorityDelta(connectorPrototype.getAcceptorPriorityDelta());
  serverConnector.setAcceptQueueSize(connectorPrototype.getAcceptQueueSize());

  managedConnectors.put(connectorConfiguration, serverConnector);
  server.addConnector(serverConnector);
  try {
    serverConnector.start();
  }
  catch (Exception e) {
    log.warn("Could not start connector: {}", connectorConfiguration, e);
    throw new RuntimeException(e);
  }

  return serverConnector;
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:58,代码来源:ConnectorManager.java

示例10: UnsupportedHttpSchemeException

import org.eclipse.jetty.http.HttpScheme; //导入依赖的package包/类
public UnsupportedHttpSchemeException(final HttpScheme httpScheme) {
  super("Unsupported HTTP Scheme: " + httpScheme);
  this.httpScheme = httpScheme;
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:5,代码来源:UnsupportedHttpSchemeException.java

示例11: getHttpScheme

import org.eclipse.jetty.http.HttpScheme; //导入依赖的package包/类
public HttpScheme getHttpScheme() {
  return httpScheme;
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:4,代码来源:UnsupportedHttpSchemeException.java

示例12: availableSchemes

import org.eclipse.jetty.http.HttpScheme; //导入依赖的package包/类
/**
 * Returns the list of available HTTP schemes. This list depends on current Jetty XML configuration (is HTTPS
 * enabled). If schema is not available, method {@link #addConnector(ConnectorConfiguration)} will reject to add it.
 */
List<HttpScheme> availableSchemes();
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:6,代码来源:ConnectorRegistrar.java

示例13: getScheme

import org.eclipse.jetty.http.HttpScheme; //导入依赖的package包/类
/**
 * The required connector scheme.
 */
HttpScheme getScheme();
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:5,代码来源:ConnectorConfiguration.java

示例14: lowLevelApiTest

import org.eclipse.jetty.http.HttpScheme; //导入依赖的package包/类
@Test
public void lowLevelApiTest() throws Exception {
    
    // start the test server
    class MyServlet extends HttpServlet { 
        
        @Override
        protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
            resp.getWriter().write("<html> <header> ...");
        }
    };
    
    WebServer server = WebServer.servlet(new MyServlet())
                                .start();

    

    
    // create a low-level jetty HTTP/2 client
    HTTP2Client lowLevelClient = new HTTP2Client();
    lowLevelClient.start();
    


    
    // create a new session which will open a (multiplexed) connection to the server  
    FuturePromise<Session> sessionFuture = new FuturePromise<>();
    lowLevelClient.connect(new InetSocketAddress("localhost", server.getLocalport()), new Session.Listener.Adapter(), sessionFuture);
    Session session = sessionFuture.get();
    
    // create the header frame 
    MetaData.Request metaData = new MetaData.Request("GET", HttpScheme.HTTP, new HostPortHttpField("localhost:" + server.getLocalport()), "/", HttpVersion.HTTP_2, new HttpFields());
    HeadersFrame frame = new HeadersFrame(1, metaData, null, true);

    // ... and perform the http transaction
    PrintingFramesHandler framesHandler = new PrintingFramesHandler();
    session.newStream(frame, new Promise.Adapter<Stream>(), framesHandler);

    
    
    
    // wait until response is received (PrintingFramesHandler will write the response frame to console) 
    framesHandler.getCompletedFuture().get();
    
    
    // shut down the client and server
    lowLevelClient.stop();
    server.stop();
}
 
开发者ID:grro,项目名称:http2,代码行数:50,代码来源:LowLevelHttp2ClientTest.java

示例15: pushApiTest

import org.eclipse.jetty.http.HttpScheme; //导入依赖的package包/类
@Test
public void pushApiTest() throws Exception {
    
    // start the test server
    class MyServlet extends HttpServlet { 
        
        @Override
        protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
            Request jettyRequest = (Request) req;
            
            if (jettyRequest.getRequestURI().equals("/myrichpage.html") && jettyRequest.isPushSupported()) {
                jettyRequest.getPushBuilder()    
                            .path("/pictures/logo.jpg")
                            .push();
            }
            
            
            if (jettyRequest.getRequestURI().equals("/myrichpage.html")) {
                resp.getWriter().write("<html> <header> ...");
            } else {
                resp.getWriter().write("���� ?JFIF   d d  �� ?Ducky  ?   P  �...");
            }
        }
    };
    
    WebServer server = WebServer.servlet(new MyServlet())
                                .start();

    
    

    // create a low-level jetty HTTP/2 client
    HTTP2Client lowLevelClient = new HTTP2Client();
    lowLevelClient.start();
    
    
    
    // create a new session which will open a (multiplexed) connection to the server  
    FuturePromise<Session> sessionFuture = new FuturePromise<>();
    lowLevelClient.connect(new InetSocketAddress("localhost", server.getLocalport()), new Session.Listener.Adapter(), sessionFuture);
    Session session = sessionFuture.get();
    
    // create the header frame
    MetaData.Request metaData = new MetaData.Request("GET", HttpScheme.HTTP, new HostPortHttpField("localhost:" + server.getLocalport()), "/myrichpage.html", HttpVersion.HTTP_2, new HttpFields());
    HeadersFrame frame = new HeadersFrame(1, metaData, null, true);

    // ... and perform the http transaction
    PrintingFramesHandler framesHandler = new PrintingFramesHandler();
    session.newStream(frame, new Promise.Adapter<Stream>(), framesHandler);

    
    
    
    // wait until response is received (PrintingFramesHandler will write the response frame to console) 
    framesHandler.getCompletedFuture().get();
    
    
    // shut down the client and server
    lowLevelClient.stop();
    server.stop();
}
 
开发者ID:grro,项目名称:http2,代码行数:62,代码来源:Http2PushTest.java


注:本文中的org.eclipse.jetty.http.HttpScheme类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。