use of io.vertx.core.http.CaseInsensitiveHeaders in project vert.x by eclipse.
the class CaseInsensitiveHeadersTest method testGetTest3.
@Test
public void testGetTest3() throws Exception {
MultiMap mmap = new CaseInsensitiveHeaders();
String name = "name";
String result = mmap.get(name);
assertNull(result);
mmap.add(name, "value");
result = mmap.get(name);
assertEquals("value", result);
}
use of io.vertx.core.http.CaseInsensitiveHeaders in project vertx-web by vert-x3.
the class HttpRequestImpl method queryParams.
@Override
public MultiMap queryParams() {
if (params == null) {
params = new CaseInsensitiveHeaders();
}
if (params.isEmpty()) {
int idx = uri.indexOf('?');
if (idx >= 0) {
QueryStringDecoder dec = new QueryStringDecoder(uri);
dec.parameters().forEach((name, value) -> params.add(name, value));
uri = uri.substring(0, idx);
}
}
return params;
}
use of io.vertx.core.http.CaseInsensitiveHeaders in project vertx-web by vert-x3.
the class SockJSHandlerTest method testCookiesRemoved.
@Test
public void testCookiesRemoved() throws Exception {
router.route("/cookiesremoved/*").handler(SockJSHandler.create(vertx).socketHandler(sock -> {
MultiMap headers = sock.headers();
String cookieHeader = headers.get("cookie");
assertNotNull(cookieHeader);
assertEquals("JSESSIONID=wibble", cookieHeader);
testComplete();
}));
MultiMap headers = new CaseInsensitiveHeaders();
headers.add("cookie", "JSESSIONID=wibble");
headers.add("cookie", "flibble=floob");
client.websocket("/cookiesremoved/websocket", headers, ws -> {
String frame = "foo";
ws.writeFrame(io.vertx.core.http.WebSocketFrame.textFrame(frame, true));
});
await();
}
use of io.vertx.core.http.CaseInsensitiveHeaders in project incubator-servicecomb-java-chassis by apache.
the class TestRestClientRequestImpl method testCookie.
@Test
public void testCookie() throws Exception {
HttpClientRequest request = new MockUp<HttpClientRequest>() {
MultiMap map = new CaseInsensitiveHeaders();
@Mock
public HttpClientRequest putHeader(CharSequence key, CharSequence val) {
map.add(key, val);
return null;
}
@Mock
public MultiMap headers() {
return map;
}
}.getMockInstance();
RestClientRequestImpl restClientRequest = new RestClientRequestImpl(request, null, null);
restClientRequest.addCookie("sessionid", "abcdefghijklmnopqrstuvwxyz");
restClientRequest.addCookie("region", "china-north");
restClientRequest.write(Buffer.buffer("I love servicecomb"));
restClientRequest.end();
Buffer buffer = restClientRequest.getBodyBuffer();
Assert.assertEquals("I love servicecomb", buffer.toString());
Assert.assertEquals("sessionid=abcdefghijklmnopqrstuvwxyz; region=china-north; ", restClientRequest.request.headers().get(HttpHeaders.COOKIE));
}
Aggregations