@Override public void start() throws Exception { WebClient client = WebClient.create(vertx); MultiMap form = MultiMap.caseInsensitiveMultiMap(); form.add("firstName", "Dale"); form.add("lastName", "Cooper"); form.add("male", "true"); client.post(8080, "localhost", "/").sendForm(form, ar -> { if (ar.succeeded()) { HttpResponse<Buffer> response = ar.result(); System.out.println("Got HTTP response with status " + response.statusCode()); } else { ar.cause().printStackTrace(); } }); } }
@Override public void start() throws Exception { WebClient client = WebClient.create(vertx); MultiMap form = MultiMap.caseInsensitiveMultiMap(); form.add("firstName", "Dale"); form.add("lastName", "Cooper"); form.add("male", "true"); client .post(8080, "localhost", "/") .putHeader("content-type", "multipart/form-data") .sendForm(form, ar -> { if (ar.succeeded()) { HttpResponse<Buffer> response = ar.result(); System.out.println("Got HTTP response with status " + response.statusCode()); } else { ar.cause().printStackTrace(); } }); } }
if (proxyOptions.getUsername() != null && proxyOptions.getPassword() != null) { if (headers == null) { headers = MultiMap.caseInsensitiveMultiMap();
assertEquals("HTTP/1.1 " + sc, statusLine.substring(0, statusLine.indexOf(' ', 9))); assertEquals("", content.substring(idx + 4)); MultiMap respHeaders = MultiMap.caseInsensitiveMultiMap(); records.forEach(record -> { int index = record.indexOf(":");
@Test public void testNotModifiedDoesNotSetAutomaticallySetContentLengthHeader() throws Exception { MultiMap respHeaders = checkEmptyHttpResponse(HttpMethod.GET, 304, MultiMap.caseInsensitiveMultiMap()); assertNull(respHeaders.get("content-length")); assertNull(respHeaders.get("transfer-encoding")); }
@Test public void testHeadDoesNotSetAutomaticallySetContentLengthHeader() throws Exception { MultiMap respHeaders = checkEmptyHttpResponse(HttpMethod.HEAD, 200, MultiMap.caseInsensitiveMultiMap()); assertNull(respHeaders.get("content-length")); assertNull(respHeaders.get("transfer-encoding")); }
@Test public void testResetContentSetsContentLengthHeader() throws Exception { MultiMap respHeaders = checkEmptyHttpResponse(HttpMethod.GET, 205, MultiMap.caseInsensitiveMultiMap()); assertEquals("0", respHeaders.get("content-length")); assertNull(respHeaders.get("transfer-encoding")); }
@Test public void testHeadRemovesTransferEncodingHeader() throws Exception { MultiMap respHeaders = checkEmptyHttpResponse(HttpMethod.HEAD, 200, MultiMap.caseInsensitiveMultiMap().set("transfer-encoding", "chunked")); assertNull(respHeaders.get("content-length")); assertNull(respHeaders.get("transfer-encoding")); }
@Test public void testNoContentRemovesContentLengthHeader() throws Exception { MultiMap respHeaders = checkEmptyHttpResponse(HttpMethod.GET, 204, MultiMap.caseInsensitiveMultiMap().set("content-length", "34")); assertNull(respHeaders.get("content-length")); assertNull(respHeaders.get("transfer-encoding")); }
@Test public void testNoContentRemovesTransferEncodingHeader() throws Exception { MultiMap respHeaders = checkEmptyHttpResponse(HttpMethod.GET, 204, MultiMap.caseInsensitiveMultiMap().set("transfer-encoding", "chunked")); assertNull(respHeaders.get("content-length")); assertNull(respHeaders.get("transfer-encoding")); }
@Test public void testNotModifiedRemovesTransferEncodingHeader() throws Exception { MultiMap respHeaders = checkEmptyHttpResponse(HttpMethod.GET, 304, MultiMap.caseInsensitiveMultiMap().set("transfer-encoding", "chunked")); assertNull(respHeaders.get("content-length")); assertNull(respHeaders.get("transfer-encoding")); }
@Test public void testResetContentRemovesTransferEncodingHeader() throws Exception { MultiMap respHeaders = checkEmptyHttpResponse(HttpMethod.GET, 205, MultiMap.caseInsensitiveMultiMap().set("transfer-encoding", "chunked")); assertEquals("0", respHeaders.get("content-length")); assertNull(respHeaders.get("transfer-encoding")); }
@Test public void testHeadAllowsContentLengthHeader() throws Exception { MultiMap respHeaders = checkEmptyHttpResponse(HttpMethod.HEAD, 200, MultiMap.caseInsensitiveMultiMap().set("content-length", "34")); assertEquals("34", respHeaders.get("content-length")); assertNull(respHeaders.get("transfer-encoding")); }
@Test public void testNotModifiedAllowsContentLengthHeader() throws Exception { MultiMap respHeaders = checkEmptyHttpResponse(HttpMethod.GET, 304, MultiMap.caseInsensitiveMultiMap().set("content-length", "34")); assertEquals("34", respHeaders.get("Content-Length")); assertNull(respHeaders.get("transfer-encoding")); }
@Test public void test1xxRemovesTransferEncodingHeader() throws Exception { MultiMap respHeaders = checkEmptyHttpResponse(HttpMethod.GET, 102, MultiMap.caseInsensitiveMultiMap().set("transfer-encoding", "chunked")); assertNull(respHeaders.get("content-length")); assertNull(respHeaders.get("transfer-encoding")); }
@Test public void test1xxRemovesContentLengthHeader() throws Exception { MultiMap respHeaders = checkEmptyHttpResponse(HttpMethod.GET, 102, MultiMap.caseInsensitiveMultiMap().set("content-length", "34")); assertNull(respHeaders.get("content-length")); assertNull(respHeaders.get("transfer-encoding")); }
lastRequestHeaders = MultiMap.caseInsensitiveMultiMap().addAll(request.headers()); if (error != 0) { request.response().setStatusCode(error).end("proxy request failed");
@Test public void testResetContentSetsContentLengthHeader() throws Exception { MultiMap respHeaders = checkEmptyHttpResponse(HttpMethod.GET, 205, MultiMap.caseInsensitiveMultiMap()); assertEquals("0", respHeaders.get("content-length")); assertNull(respHeaders.get("transfer-encoding")); }
@Test public void testHeadAllowsContentLengthHeader() throws Exception { MultiMap respHeaders = checkEmptyHttpResponse(HttpMethod.HEAD, 200, MultiMap.caseInsensitiveMultiMap().set("content-length", "34")); assertEquals("34", respHeaders.get("content-length")); assertNull(respHeaders.get("transfer-encoding")); }
@Test public void testNoContentRemovesContentLengthHeader() throws Exception { MultiMap respHeaders = checkEmptyHttpResponse(HttpMethod.GET, 204, MultiMap.caseInsensitiveMultiMap().set("content-length", "34")); assertNull(respHeaders.get("content-length")); assertNull(respHeaders.get("transfer-encoding")); }