Search in sources :

Example 66 with CaseInsensitiveHeaders

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);
}
Also used : MultiMap(io.vertx.core.MultiMap) CaseInsensitiveHeaders(io.vertx.core.http.CaseInsensitiveHeaders) Test(org.junit.Test)

Example 67 with CaseInsensitiveHeaders

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;
}
Also used : QueryStringDecoder(io.netty.handler.codec.http.QueryStringDecoder) CaseInsensitiveHeaders(io.vertx.core.http.CaseInsensitiveHeaders)

Example 68 with CaseInsensitiveHeaders

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();
}
Also used : MultiMap(io.vertx.core.MultiMap) Test(org.junit.Test) WebSocket(io.vertx.core.http.WebSocket) BodyHandler(io.vertx.ext.web.handler.BodyHandler) AtomicReference(java.util.concurrent.atomic.AtomicReference) LoggerFactory(io.vertx.core.logging.LoggerFactory) ArrayList(java.util.ArrayList) TimeUnit(java.util.concurrent.TimeUnit) CountDownLatch(java.util.concurrent.CountDownLatch) List(java.util.List) FrameType(io.vertx.core.http.impl.FrameType) Buffer(io.vertx.core.buffer.Buffer) TestUtils(io.vertx.test.core.TestUtils) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) BiConsumer(java.util.function.BiConsumer) JsonObject(io.vertx.core.json.JsonObject) WebSocketFrameImpl(io.vertx.core.http.impl.ws.WebSocketFrameImpl) Logger(io.vertx.core.logging.Logger) PermittedOptions(io.vertx.ext.bridge.PermittedOptions) WebSocketFrame(io.vertx.core.http.WebSocketFrame) WebTestBase(io.vertx.ext.web.WebTestBase) CaseInsensitiveHeaders(io.vertx.core.http.CaseInsensitiveHeaders) MultiMap(io.vertx.core.MultiMap) CaseInsensitiveHeaders(io.vertx.core.http.CaseInsensitiveHeaders) Test(org.junit.Test)

Example 69 with CaseInsensitiveHeaders

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));
}
Also used : Buffer(io.vertx.core.buffer.Buffer) MultiMap(io.vertx.core.MultiMap) HttpClientRequest(io.vertx.core.http.HttpClientRequest) CaseInsensitiveHeaders(io.vertx.core.http.CaseInsensitiveHeaders) Mock(mockit.Mock) Test(org.junit.Test)

Aggregations

CaseInsensitiveHeaders (io.vertx.core.http.CaseInsensitiveHeaders)69 MultiMap (io.vertx.core.MultiMap)65 Test (org.junit.Test)64 ArrayList (java.util.ArrayList)10 HashMap (java.util.HashMap)10 Buffer (io.vertx.core.buffer.Buffer)3 VxApiServerURLInfo (com.szmirren.vxApi.core.entity.VxApiServerURLInfo)2 VxApiTrackInfos (com.szmirren.vxApi.core.entity.VxApiTrackInfos)2 VxApiParamOptions (com.szmirren.vxApi.core.options.VxApiParamOptions)2 HttpClientRequest (io.vertx.core.http.HttpClientRequest)2 HttpServerResponse (io.vertx.core.http.HttpServerResponse)2 JsonObject (io.vertx.core.json.JsonObject)2 ConnectException (java.net.ConnectException)2 Map (java.util.Map)2 TimeoutException (java.util.concurrent.TimeoutException)2 QueryStringDecoder (io.netty.handler.codec.http.QueryStringDecoder)1 QueryStringEncoder (io.netty.handler.codec.http.QueryStringEncoder)1 WebSocket (io.vertx.core.http.WebSocket)1 WebSocketFrame (io.vertx.core.http.WebSocketFrame)1 FrameType (io.vertx.core.http.impl.FrameType)1