@Test public void testHeader() throws Exception { HttpRequest req = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/"); req.headers().add(HeaderNames.ACCEPT_ENCODING, "gzip, deflate"); req.headers().add(HeaderNames.ACCEPT_LANGUAGE, "en-US"); req.headers().add(HeaderNames.ACCEPT_CHARSET, "utf-8"); req.headers().add("test", "a").add("test", "b"); ContextFromVertx context = new ContextFromVertx(vertx, vertx.getOrCreateContext(), accessor, RequestFromVertXTest.create(req)); assertThat(context.headers().containsKey(HeaderNames.ACCEPT_LANGUAGE)).isTrue(); assertThat(context.header(HeaderNames.ACCEPT_LANGUAGE)).isEqualTo("en-US"); assertThat(context.headers().get("test")).containsExactly("a", "b"); assertThat(context.headers("test")).containsExactly("a", "b"); assertThat(context.headers().get("missing")).isNull(); assertThat(context.header("missing")).isNull(); }
@Override public String header(String name) { List<String> list = request.headers().get(name); if (list != null && !list.isEmpty()) { return list.get(0); } return null; }
ContextFromVertx implements Context { @Override public String header(String name) { List<String> list = request.headers().get(name); if (list != null && !list.isEmpty()) { return list.get(0); } return null; } }
ContextFromVertx implements Context { @Override public String header(String name) { List<String> list = request.headers().get(name); if (list != null && !list.isEmpty()) { return list.get(0); } return null; } ContextFromVertx(Vertx vertx, io.vertx.core.Context vertxContext, ServiceAccessor accessor, HttpServerRequest req); }
ContextFromVertx implements Context { @Override public String header(String name) { List<String> list = request.headers().get(name); if (list != null && !list.isEmpty()) { return list.get(0); } return null; } ContextFromVertx(Vertx vertx, io.vertx.core.Context vertxContext, ServiceAccessor accessor, HttpServerRequest req); @Override Long id(); @Override Request request(); @Override String path(); @Override FlashCookie flash(); @Override SessionCookie session(); @Override Cookie cookie(String cookieName); @Override boolean hasCookie(String cookieName); @Override Cookies cookies(); @Override String contextPath(); @Override String parameter(String name); @Override Map<String, List<String>> attributes(); @Override Map<String, List<String>> form(); @Override List<String> parameterMultipleValues(String name); @Override String parameter(String name, String defaultValue); @Override Integer parameterAsInteger(String name); @Override Integer parameterAsInteger(String name, Integer defaultValue); @Override Boolean parameterAsBoolean(String name); @Override Boolean parameterAsBoolean(String name, boolean defaultValue); @Override String parameterFromPath(String name); @Override String parameterFromPathEncoded(String name); @Override Integer parameterFromPathAsInteger(String key); @Override Map<String, List<String>> parameters(); @Override String header(String name); @Override List<String> headers(String name); @Override Map<String, List<String>> headers(); @Override String cookieValue(String name); @Override T body(Class<T> classOfT); @Override T body(Class<T> classOfT, Type genericType); String body(); @Override byte[] raw(); @Override BufferedReader reader(); @Override Route route(); void route(Route route); @Override boolean isMultipart(); @Override Collection<? extends FileItem> files(); @Override FileItem file(String name); void cleanup(); boolean ready(); Vertx vertx(); io.vertx.core.Context vertxContext(); @Override String toString(); }
ContextFromVertx implements Context { @Override public String header(String name) { List<String> list = request.headers().get(name); if (list != null && !list.isEmpty()) { return list.get(0); } return null; } ContextFromVertx(Vertx vertx, io.vertx.core.Context vertxContext, ServiceAccessor accessor, HttpServerRequest req); @Override Long id(); @Override Request request(); @Override String path(); @Override FlashCookie flash(); @Override SessionCookie session(); @Override Cookie cookie(String cookieName); @Override boolean hasCookie(String cookieName); @Override Cookies cookies(); @Override String contextPath(); @Override String parameter(String name); @Override Map<String, List<String>> attributes(); @Override Map<String, List<String>> form(); @Override List<String> parameterMultipleValues(String name); @Override String parameter(String name, String defaultValue); @Override Integer parameterAsInteger(String name); @Override Integer parameterAsInteger(String name, Integer defaultValue); @Override Boolean parameterAsBoolean(String name); @Override Boolean parameterAsBoolean(String name, boolean defaultValue); @Override String parameterFromPath(String name); @Override String parameterFromPathEncoded(String name); @Override Integer parameterFromPathAsInteger(String key); @Override Map<String, List<String>> parameters(); @Override String header(String name); @Override List<String> headers(String name); @Override Map<String, List<String>> headers(); @Override String cookieValue(String name); @Override T body(Class<T> classOfT); @Override T body(Class<T> classOfT, Type genericType); String body(); @Override byte[] raw(); @Override BufferedReader reader(); @Override Route route(); void route(Route route); @Override boolean isMultipart(); @Override Collection<? extends FileItem> files(); @Override FileItem file(String name); void cleanup(); boolean ready(); Vertx vertx(); io.vertx.core.Context vertxContext(); @Override String toString();  }