use of io.vertx.core.http.CaseInsensitiveHeaders in project vert.x by eclipse.
the class ClusteredMessage method decodeHeaders.
private void decodeHeaders() {
int length = wireBuffer.getInt(headersPos);
if (length != 4) {
headersPos += 4;
int numHeaders = wireBuffer.getInt(headersPos);
headersPos += 4;
headers = new CaseInsensitiveHeaders();
for (int i = 0; i < numHeaders; i++) {
int keyLength = wireBuffer.getInt(headersPos);
headersPos += 4;
byte[] bytes = wireBuffer.getBytes(headersPos, headersPos + keyLength);
String key = new String(bytes, CharsetUtil.UTF_8);
headersPos += keyLength;
int valLength = wireBuffer.getInt(headersPos);
headersPos += 4;
bytes = wireBuffer.getBytes(headersPos, headersPos + valLength);
String val = new String(bytes, CharsetUtil.UTF_8);
headersPos += valLength;
headers.add(key, val);
}
}
headersPos = 0;
}
use of io.vertx.core.http.CaseInsensitiveHeaders 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.http.CaseInsensitiveHeaders 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());
}
use of io.vertx.core.http.CaseInsensitiveHeaders in project vert.x by eclipse.
the class CaseInsensitiveHeadersTest method testIsEmptyTest1.
@Test
public void testIsEmptyTest1() throws Exception {
MultiMap mmap = new CaseInsensitiveHeaders();
assertTrue(mmap.isEmpty());
}
use of io.vertx.core.http.CaseInsensitiveHeaders in project vert.x by eclipse.
the class CaseInsensitiveHeadersTest method testToString.
@Test
public void testToString() {
MultiMap mm = new CaseInsensitiveHeaders();
assertEquals("", mm.toString());
mm.add("Header1", "Value1");
assertEquals("Header1: Value1\n", sortByLine(mm.toString()));
mm.add("Header2", "Value2");
assertEquals("Header1: Value1\n" + "Header2: Value2\n", sortByLine(mm.toString()));
mm.add("Header1", "Value3");
assertEquals("Header1: Value1\n" + "Header1: Value3\n" + "Header2: Value2\n", sortByLine(mm.toString()));
mm.remove("Header1");
assertEquals("Header2: Value2\n", sortByLine(mm.toString()));
mm.set("Header2", "Value4");
assertEquals("Header2: Value4\n", sortByLine(mm.toString()));
}
Aggregations