List of usage examples for io.netty.handler.codec.http2 Http2Headers method
Http2Headers method(CharSequence value);
From source file:io.vertx.core.http.impl.Http2ServerConnection.java
License:Open Source License
synchronized void sendPush(int streamId, String host, HttpMethod method, MultiMap headers, String path, Handler<AsyncResult<HttpServerResponse>> completionHandler) { Http2Headers headers_ = new DefaultHttp2Headers(); if (method == HttpMethod.OTHER) { throw new IllegalArgumentException("Cannot push HttpMethod.OTHER"); } else {/*from www . j a va2 s.c o m*/ headers_.method(method.name()); } headers_.path(path); headers_.scheme(isSsl() ? "https" : "http"); if (host != null) { headers_.authority(host); } if (headers != null) { headers.forEach(header -> headers_.add(header.getKey(), header.getValue())); } handler.writePushPromise(streamId, headers_, new Handler<AsyncResult<Integer>>() { @Override public void handle(AsyncResult<Integer> ar) { if (ar.succeeded()) { synchronized (Http2ServerConnection.this) { int promisedStreamId = ar.result(); String contentEncoding = HttpUtils.determineContentEncoding(headers_); Http2Stream promisedStream = handler.connection().stream(promisedStreamId); boolean writable = handler.encoder().flowController().isWritable(promisedStream); Push push = new Push(promisedStream, contentEncoding, method, path, writable, completionHandler); streams.put(promisedStreamId, push); if (maxConcurrentStreams == null || concurrentStreams < maxConcurrentStreams) { concurrentStreams++; context.executeFromIO(push::complete); } else { pendingPushes.add(push); } } } else { context.executeFromIO(() -> { completionHandler.handle(Future.failedFuture(ar.cause())); }); } } }); }