use of io.vertx.core.MultiMap in project vert.x by eclipse.
the class Http2ClientConnection method onPushPromiseRead.
@Override
public synchronized void onPushPromiseRead(ChannelHandlerContext ctx, int streamId, int promisedStreamId, Http2Headers headers, int padding) throws Http2Exception {
Http2ClientStream stream = (Http2ClientStream) streams.get(streamId);
if (stream != null) {
Handler<HttpClientRequest> pushHandler = stream.pushHandler();
if (pushHandler != null) {
context.executeFromIO(() -> {
String rawMethod = headers.method().toString();
HttpMethod method = HttpUtils.toVertxMethod(rawMethod);
String uri = headers.path().toString();
String host = headers.authority() != null ? headers.authority().toString() : null;
MultiMap headersMap = new Http2HeadersAdaptor(headers);
Http2Stream promisedStream = handler.connection().stream(promisedStreamId);
int port = remoteAddress().port();
HttpClientRequestPushPromise pushReq = new HttpClientRequestPushPromise(this, promisedStream, http2Pool.client, isSsl(), method, rawMethod, uri, host, port, headersMap);
if (metrics.isEnabled()) {
pushReq.metric(metrics.responsePushed(queueMetric, metric(), localAddress(), remoteAddress(), pushReq));
}
streams.put(promisedStreamId, pushReq.getStream());
pushHandler.handle(pushReq);
});
return;
}
}
handler.writeReset(promisedStreamId, Http2Error.CANCEL.code());
}
use of io.vertx.core.MultiMap in project vert.x by eclipse.
the class HTTPExamples method example24.
public void example24(HttpServerRequest request) {
HttpServerResponse response = request.response();
response.setChunked(true);
MultiMap trailers = response.trailers();
trailers.set("X-wibble", "woobble").set("X-quux", "flooble");
}
use of io.vertx.core.MultiMap in project vert.x by eclipse.
the class HTTPExamples method example37.
public void example37(HttpClientRequest request) {
// Write some headers using the headers() multimap
MultiMap headers = request.headers();
headers.set("content-type", "application/json").set("other-header", "foo");
}
use of io.vertx.core.MultiMap in project vert.x by eclipse.
the class CaseInsensitiveHeadersTest method testSetIterableEmpty.
@Test
public void testSetIterableEmpty() throws Exception {
MultiMap mmap = new CaseInsensitiveHeaders();
String name = "name";
List<String> values = new ArrayList<String>();
MultiMap result = mmap.set(name, values);
assertNotNull(result);
assertTrue(result.isEmpty());
assertEquals(0, result.size());
assertEquals("", result.toString());
}
use of io.vertx.core.MultiMap in project vert.x by eclipse.
the class CaseInsensitiveHeadersTest method testRemoveHashColl.
@Test
public void testRemoveHashColl() {
MultiMap mm = new CaseInsensitiveHeaders();
String name1 = "AZ";
String name2 = "Y";
String name3 = "RZ";
assertTrue("hash error", hash(name1) == hash(name2));
mm.add(name1, "value1");
mm.add(name2, "value2");
mm.add(name3, "value3");
mm.add(name1, "value4");
mm.add(name2, "value5");
mm.add(name3, "value6");
assertEquals(3, mm.size());
mm.remove(name1);
mm.remove(name2);
assertEquals(1, mm.size());
mm = new CaseInsensitiveHeaders();
name1 = "A";
name2 = "R";
assertTrue("hash error", index(hash(name1)) == index(hash(name2)));
mm.add(name1, "value1");
mm.add(name2, "value2");
assertEquals(2, mm.size());
mm.remove(name1);
mm.remove(name2);
assertTrue("not empty", mm.isEmpty());
}
Aggregations