本文整理汇总了Java中io.vertx.core.http.HttpVersion类的典型用法代码示例。如果您正苦于以下问题:Java HttpVersion类的具体用法?Java HttpVersion怎么用?Java HttpVersion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HttpVersion类属于io.vertx.core.http包,在下文中一共展示了HttpVersion类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createHttpClientOptions
import io.vertx.core.http.HttpVersion; //导入依赖的package包/类
@Override
public HttpClientOptions createHttpClientOptions() {
HttpVersion ver = ServiceRegistryConfig.INSTANCE.getHttpVersion();
HttpClientOptions httpClientOptions = new HttpClientOptions();
httpClientOptions.setProtocolVersion(ver);
httpClientOptions.setConnectTimeout(ServiceRegistryConfig.INSTANCE.getConnectionTimeout());
httpClientOptions.setIdleTimeout(ServiceRegistryConfig.INSTANCE.getIdleWatchTimeout());
if (ver == HttpVersion.HTTP_2) {
LOGGER.debug("service center ws client protocol version is HTTP/2");
httpClientOptions.setHttp2ClearTextUpgrade(false);
}
if (ServiceRegistryConfig.INSTANCE.isSsl()) {
LOGGER.debug("service center ws client performs requests over TLS");
VertxTLSBuilder.buildHttpClientOptions(SSL_KEY, httpClientOptions);
}
return httpClientOptions;
}
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:18,代码来源:WebsocketClientPool.java
示例2: createHttpClientOptions
import io.vertx.core.http.HttpVersion; //导入依赖的package包/类
@Override
public HttpClientOptions createHttpClientOptions() {
HttpVersion ver = ServiceRegistryConfig.INSTANCE.getHttpVersion();
HttpClientOptions httpClientOptions = new HttpClientOptions();
httpClientOptions.setProtocolVersion(ver);
httpClientOptions.setConnectTimeout(ServiceRegistryConfig.INSTANCE.getConnectionTimeout());
httpClientOptions.setIdleTimeout(ServiceRegistryConfig.INSTANCE.getIdleConnectionTimeout());
if (ServiceRegistryConfig.INSTANCE.isProxyEnable()) {
ProxyOptions proxy = new ProxyOptions();
proxy.setHost(ServiceRegistryConfig.INSTANCE.getProxyHost());
proxy.setPort(ServiceRegistryConfig.INSTANCE.getProxyPort());
proxy.setUsername(ServiceRegistryConfig.INSTANCE.getProxyUsername());
proxy.setPassword(ServiceRegistryConfig.INSTANCE.getProxyPasswd());
httpClientOptions.setProxyOptions(proxy);
}
if (ver == HttpVersion.HTTP_2) {
LOGGER.debug("service center client protocol version is HTTP/2");
httpClientOptions.setHttp2ClearTextUpgrade(false);
}
if (ServiceRegistryConfig.INSTANCE.isSsl()) {
LOGGER.debug("service center client performs requests over TLS");
VertxTLSBuilder.buildHttpClientOptions(SSL_KEY, httpClientOptions);
}
return httpClientOptions;
}
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:26,代码来源:HttpClientPool.java
示例3: testPrivateMethodCreateHttpClientOptions
import io.vertx.core.http.HttpVersion; //导入依赖的package包/类
@Test
public void testPrivateMethodCreateHttpClientOptions() {
MicroserviceFactory microserviceFactory = new MicroserviceFactory();
Microservice microservice = microserviceFactory.create("app", "ms");
oClient.registerMicroservice(microservice);
oClient.registerMicroserviceInstance(microservice.getInstance());
new MockUp<ServiceRegistryConfig>() {
@Mock
public HttpVersion getHttpVersion() {
return HttpVersion.HTTP_2;
}
@Mock
public boolean isSsl() {
return true;
}
};
try {
oClient.init();
HttpClientOptions httpClientOptions = Deencapsulation.invoke(oClient, "createHttpClientOptions");
Assert.assertNotNull(httpClientOptions);
Assert.assertEquals(80, httpClientOptions.getDefaultPort());
} catch (Exception e) {
Assert.assertNotNull(e);
}
}
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:27,代码来源:TestServiceRegistryClientImpl.java
示例4: getFormattedElement
import io.vertx.core.http.HttpVersion; //导入依赖的package包/类
@Test
public void getFormattedElement() {
AccessLogParam param = new AccessLogParam();
RoutingContext mockContext = Mockito.mock(RoutingContext.class);
HttpServerRequest request = Mockito.mock(HttpServerRequest.class);
String uri = "/test/uri";
param.setRoutingContext(mockContext);
Mockito.when(mockContext.request()).thenReturn(request);
Mockito.when(request.method()).thenReturn(HttpMethod.DELETE);
Mockito.when(request.path()).thenReturn(uri);
Mockito.when(request.version()).thenReturn(HttpVersion.HTTP_1_1);
String result = ELEMENT.getFormattedElement(param);
assertEquals("\"DELETE " + uri + " HTTP/1.1\"", result);
}
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:18,代码来源:FirstLineOfRequestElementTest.java
示例5: getFormattedElement
import io.vertx.core.http.HttpVersion; //导入依赖的package包/类
@Test
public void getFormattedElement() {
AccessLogParam param = new AccessLogParam();
RoutingContext context = Mockito.mock(RoutingContext.class);
HttpServerRequest request = Mockito.mock(HttpServerRequest.class);
param.setRoutingContext(context);
Mockito.when(context.request()).thenReturn(request);
Mockito.when(request.version()).thenReturn(HttpVersion.HTTP_1_1);
String result = new VersionOrProtocolElement().getFormattedElement(param);
assertEquals("HTTP/1.1", result);
Mockito.when(request.version()).thenReturn(HttpVersion.HTTP_1_0);
result = new VersionOrProtocolElement().getFormattedElement(param);
assertEquals("HTTP/1.0", result);
Mockito.when(request.version()).thenReturn(HttpVersion.HTTP_2);
result = new VersionOrProtocolElement().getFormattedElement(param);
assertEquals("HTTP/2.0", result);
}
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:22,代码来源:VersionOrProtocolElementTest.java
示例6: handle
import io.vertx.core.http.HttpVersion; //导入依赖的package包/类
@Override
public void handle(RoutingContext context) {
// common logging data
long timestamp = System.currentTimeMillis();
String remoteClient = getClientAddress(context.request().remoteAddress());
HttpMethod method = context.request().method();
String uri = context.request().uri();
HttpVersion version = context.request().version();
if (immediate) {
log(context, timestamp, remoteClient, version, method, uri);
} else {
context.addBodyEndHandler(v -> log(context, timestamp, remoteClient, version, method, uri));
}
context.next();
}
开发者ID:vert-x3,项目名称:vertx-web,代码行数:19,代码来源:LoggerHandlerImpl.java
示例7: testIsKeepAlive
import io.vertx.core.http.HttpVersion; //导入依赖的package包/类
@Test
public void testIsKeepAlive() throws Exception {
MultiMap headers = MultiMap.caseInsensitiveMultiMap();
HttpServerRequest req = mock(HttpServerRequest.class);
when(req.headers()).thenReturn(headers);
// Connection header set.
headers.add(HeaderNames.CONNECTION, HttpUtils.CLOSE);
assertThat(HttpUtils.isKeepAlive(req)).isFalse();
headers.add(HeaderNames.CONNECTION, HttpUtils.KEEP_ALIVE);
assertThat(HttpUtils.isKeepAlive(req)).isTrue();
// Unset connection header
headers.clear();
when(req.version()).thenReturn(HttpVersion.HTTP_1_1);
assertThat(HttpUtils.isKeepAlive(req)).isTrue();
when(req.version()).thenReturn(HttpVersion.HTTP_1_0);
assertThat(HttpUtils.isKeepAlive(req)).isFalse();
}
开发者ID:wisdom-framework,项目名称:wisdom,代码行数:22,代码来源:HttpUtilsTest.java
示例8: testHttpClientPool
import io.vertx.core.http.HttpVersion; //导入依赖的package包/类
@Test
public void testHttpClientPool() {
new MockUp<ServiceRegistryConfig>() {
@Mock
public HttpVersion getHttpVersion() {
return HttpVersion.HTTP_2;
}
@Mock
public boolean isSsl() {
return true;
}
};
HttpClientPool.INSTANCE.create();
}
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:16,代码来源:TestClientPool.java
示例9: testWebsocketClientPool
import io.vertx.core.http.HttpVersion; //导入依赖的package包/类
@Test
public void testWebsocketClientPool() {
new MockUp<ServiceRegistryConfig>() {
@Mock
public HttpVersion getHttpVersion() {
return HttpVersion.HTTP_2;
}
@Mock
public boolean isSsl() {
return true;
}
};
WebsocketClientPool.INSTANCE.create();
}
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:16,代码来源:TestClientPool.java
示例10: getStringVersion
import io.vertx.core.http.HttpVersion; //导入依赖的package包/类
private String getStringVersion(HttpVersion version) {
switch (version) {
case HTTP_2:
return "HTTP/2.0";
case HTTP_1_0:
return "HTTP/1.0";
case HTTP_1_1:
return "HTTP/1.1";
default:
return EMPTY_RESULT;
}
}
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:13,代码来源:VersionOrProtocolElement.java
示例11: TypedParamInjectorRegistry
import io.vertx.core.http.HttpVersion; //导入依赖的package包/类
@SuppressWarnings({"unchecked", "rawtypes"})
public TypedParamInjectorRegistry(Config config) {
map = new HashMap<>();
registerInjector(Vertx.class, new VertxParamInjector());
registerInjector(Session.class, new SessionParamInjector());
registerInjector(RoutingContext.class, new RoutingContextParamInjector());
registerInjector(Payload.class, new PayloadParamInjector());
registerInjector(PaginationContext.class, new PaginationContextParamInjector());
registerInjector(EventBus.class, new EventBusParamInjector());
registerInjector(ResourceBundle.class, new ResourceBundleParamInjector(config));
registerInjector(HttpServerRequest.class, new RequestParamInjector());
registerInjector(HttpServerResponse.class, new ResponseParamInjector());
registerInjector(SocketAddress.class, new SocketAddressParamInjector());
registerInjector(HttpVersion.class, new HttpVersionParamInjector());
}
开发者ID:aesteve,项目名称:nubes,代码行数:16,代码来源:TypedParamInjectorRegistry.java
示例12: sendFrame
import io.vertx.core.http.HttpVersion; //导入依赖的package包/类
public void sendFrame(String body) {
if (log.isTraceEnabled()) log.trace("XHR sending frame");
if (!headersWritten) {
HttpServerResponse resp = rc.response();
resp.putHeader("Content-Type", "application/javascript; charset=UTF-8");
setJSESSIONID(options, rc);
setCORS(rc);
if (rc.request().version() != HttpVersion.HTTP_1_0) {
resp.setChunked(true);
} else {
resp.putHeader("Content-Length", "0");
}
headersWritten = true;
}
}
开发者ID:vert-x3,项目名称:vertx-web,代码行数:16,代码来源:XhrTransport.java
示例13: testNoHttp2Push
import io.vertx.core.http.HttpVersion; //导入依赖的package包/类
@Test
public void testNoHttp2Push() throws Exception {
stat.setWebRoot("webroot/somedir3");
router.route().handler(stat);
HttpServer http2Server = vertx.createHttpServer(new HttpServerOptions()
.setUseAlpn(true)
.setSsl(true)
.setPemKeyCertOptions(new PemKeyCertOptions().setKeyPath("tls/server-key.pem").setCertPath("tls/server-cert.pem")));
http2Server.requestHandler(router::accept).listen(8443);
HttpClientOptions options = new HttpClientOptions()
.setSsl(true)
.setUseAlpn(true)
.setProtocolVersion(HttpVersion.HTTP_2)
.setPemTrustOptions(new PemTrustOptions().addCertPath("tls/server-cert.pem"));
HttpClient client = vertx.createHttpClient(options);
HttpClientRequest request = client.get(8443, "localhost", "/testLinkPreload.html", resp -> {
assertEquals(200, resp.statusCode());
assertEquals(HttpVersion.HTTP_2, resp.version());
resp.bodyHandler(this::assertNotNull);
testComplete();
});
request.pushHandler(pushedReq -> pushedReq.handler(pushedResp -> {
fail();
}));
request.end();
await();
}
开发者ID:vert-x3,项目名称:vertx-web,代码行数:29,代码来源:StaticHandlerTest.java
示例14: testHttp2Push
import io.vertx.core.http.HttpVersion; //导入依赖的package包/类
@Test
public void testHttp2Push() throws Exception {
List<Http2PushMapping> mappings = new ArrayList<>();
mappings.add(new Http2PushMapping("style.css", "style", false));
mappings.add(new Http2PushMapping("coin.png", "image", false));
stat.setHttp2PushMapping(mappings)
.setWebRoot("webroot/somedir3");
router.route().handler(stat);
HttpServer http2Server = vertx.createHttpServer(new HttpServerOptions()
.setUseAlpn(true)
.setSsl(true)
.setPemKeyCertOptions(new PemKeyCertOptions().setKeyPath("tls/server-key.pem").setCertPath("tls/server-cert.pem")));
http2Server.requestHandler(router::accept).listen(8443);
HttpClientOptions options = new HttpClientOptions()
.setSsl(true)
.setUseAlpn(true)
.setProtocolVersion(HttpVersion.HTTP_2)
.setPemTrustOptions(new PemTrustOptions().addCertPath("tls/server-cert.pem"));
HttpClient client = vertx.createHttpClient(options);
HttpClientRequest request = client.get(8443, "localhost", "/testLinkPreload.html", resp -> {
assertEquals(200, resp.statusCode());
assertEquals(HttpVersion.HTTP_2, resp.version());
resp.bodyHandler(this::assertNotNull);
});
CountDownLatch latch = new CountDownLatch(2);
request.pushHandler(pushedReq -> pushedReq.handler(pushedResp -> {
assertNotNull(pushedResp);
pushedResp.bodyHandler(this::assertNotNull);
latch.countDown();
}));
request.end();
latch.await();
}
开发者ID:vert-x3,项目名称:vertx-web,代码行数:35,代码来源:StaticHandlerTest.java
示例15: isKeepAlive
import io.vertx.core.http.HttpVersion; //导入依赖的package包/类
/**
* Checks whether the given request should be closed or not once completed.
*
* @param request the request
* @return {@code true} if the connection is marked as {@literal keep-alive}, and so must not be closed. {@code
* false} otherwise. Notice that if not set in the request, the default value depends on the HTTP version.
*/
public static boolean isKeepAlive(HttpServerRequest request) {
String connection = request.headers().get(HeaderNames.CONNECTION);
if (connection != null && connection.equalsIgnoreCase(CLOSE)) {
return false;
}
if (request.version() == HttpVersion.HTTP_1_1) {
return !CLOSE.equalsIgnoreCase(connection);
} else {
return KEEP_ALIVE.equalsIgnoreCase(connection);
}
}
开发者ID:wisdom-framework,项目名称:wisdom,代码行数:19,代码来源:HttpUtils.java
示例16: buildResponse
import io.vertx.core.http.HttpVersion; //导入依赖的package包/类
public static void buildResponse(HttpServerResponse httpServerResponse, ApiResponse amanResponse, HttpVersion httpVersion) {
amanResponse.getHeaders().forEach(e -> {
if (httpVersion == HttpVersion.HTTP_1_0 || httpVersion == HttpVersion.HTTP_1_1 || !e.getKey().equals("Connection")) {
httpServerResponse.headers().add(e.getKey(), e.getValue());
}
});
httpServerResponse.setStatusCode(amanResponse.getCode());
httpServerResponse.setStatusMessage(amanResponse.getMessage() == null ? "" : amanResponse.getMessage());
}
开发者ID:apiman,项目名称:apiman,代码行数:10,代码来源:HttpApiFactory.java
示例17: getHttpVersion
import io.vertx.core.http.HttpVersion; //导入依赖的package包/类
public HttpVersion getHttpVersion() {
DynamicStringProperty property =
DynamicPropertyFactory.getInstance()
.getStringProperty("cse.service.registry.client.httpVersion", "HTTP_1_1");
return HttpVersion.valueOf(property.get());
}
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:7,代码来源:ServiceRegistryConfig.java
示例18: version
import io.vertx.core.http.HttpVersion; //导入依赖的package包/类
@Override
public HttpVersion version() {
return HttpVersion.HTTP_1_1;
}
开发者ID:noseka1,项目名称:vertx-aws-lambda,代码行数:5,代码来源:HttpServerRequestImpl.java
示例19: testVersion
import io.vertx.core.http.HttpVersion; //导入依赖的package包/类
@Test
public void testVersion(TestContext context) {
context.assertEquals(HttpVersion.HTTP_1_1, request.version());
}
开发者ID:noseka1,项目名称:vertx-aws-lambda,代码行数:5,代码来源:HttpServerRequestImplTest.java
示例20: getAlpnVersions
import io.vertx.core.http.HttpVersion; //导入依赖的package包/类
@Override
public List<HttpVersion> getAlpnVersions() {
return options.getAlpnVersions();
}
开发者ID:GwtDomino,项目名称:domino,代码行数:5,代码来源:ImmutableHttpServerOptions.java
注:本文中的io.vertx.core.http.HttpVersion类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论