@Test public void testCookieHeader() throws URISyntaxException, IOException { Multimap<String, String> headers = LinkedHashMultimap.create(); headers.put("key1", "value1"); headers.put("Set-Cookie", "YSxiLGM=, ZCxlLGY="); int status = 200; String str = "Hello world"; RecordedStringHttpBody recordedStringHttpBody = new RecordedStringHttpBody(str); RecordedHttpResponse recordedHttpResponse = new RecordedHttpResponse(status, headers, recordedStringHttpBody); FullHttpResponse fullHttpResponse = NettyHttpResponseMapper.from(recordedHttpResponse); Assert.assertEquals(fullHttpResponse.getStatus().code(), status); Assert.assertEquals(fullHttpResponse.headers().get("key1"), "value1"); List<String> headrValues = fullHttpResponse.headers().getAll("Set-Cookie"); Assert.assertEquals(headrValues.size(), 1); Assert.assertTrue(headrValues.contains("YSxiLGM=, ZCxlLGY=")); }
public static FullHttpResponse from(RecordedHttpResponse recordedHttpResponse) throws IOException { FullHttpResponse fullHttpResponse; HttpResponseStatus status = HttpResponseStatus.valueOf(recordedHttpResponse.getStatus()); if (recordedHttpResponse.hasHttpBody()) { ByteBuf content = wrappedBuffer(createHttpBodyBytes(recordedHttpResponse)); fullHttpResponse = new DefaultFullHttpResponse(HTTP_1_1, status, content); } else { fullHttpResponse = new DefaultFullHttpResponse(HTTP_1_1, status); } for (Map.Entry<String, String> header : recordedHttpResponse.getHeaders().entries()) { fullHttpResponse.headers().add(header.getKey(), header.getValue()); } return fullHttpResponse; }
NettyHttpResponseMapper { public static FullHttpResponse from(RecordedHttpResponse recordedHttpResponse) throws IOException { FullHttpResponse fullHttpResponse; HttpResponseStatus status = HttpResponseStatus.valueOf(recordedHttpResponse.getStatus()); if (recordedHttpResponse.hasHttpBody()) { ByteBuf content = wrappedBuffer(createHttpBodyBytes(recordedHttpResponse)); fullHttpResponse = new DefaultFullHttpResponse(HTTP_1_1, status, content); } else { fullHttpResponse = new DefaultFullHttpResponse(HTTP_1_1, status); } for (Map.Entry<String, String> header : recordedHttpResponse.getHeaders().entries()) { fullHttpResponse.headers().add(header.getKey(), header.getValue()); } return fullHttpResponse; } }
NettyHttpResponseMapper { public static FullHttpResponse from(RecordedHttpResponse recordedHttpResponse) throws IOException { FullHttpResponse fullHttpResponse; HttpResponseStatus status = HttpResponseStatus.valueOf(recordedHttpResponse.getStatus()); if (recordedHttpResponse.hasHttpBody()) { ByteBuf content = wrappedBuffer(createHttpBodyBytes(recordedHttpResponse)); fullHttpResponse = new DefaultFullHttpResponse(HTTP_1_1, status, content); } else { fullHttpResponse = new DefaultFullHttpResponse(HTTP_1_1, status); } for (Map.Entry<String, String> header : recordedHttpResponse.getHeaders().entries()) { fullHttpResponse.headers().add(header.getKey(), header.getValue()); } return fullHttpResponse; } private  NettyHttpResponseMapper(); }
NettyHttpResponseMapper { public static FullHttpResponse from(RecordedHttpResponse recordedHttpResponse) throws IOException { FullHttpResponse fullHttpResponse; HttpResponseStatus status = HttpResponseStatus.valueOf(recordedHttpResponse.getStatus()); if (recordedHttpResponse.hasHttpBody()) { ByteBuf content = wrappedBuffer(createHttpBodyBytes(recordedHttpResponse)); fullHttpResponse = new DefaultFullHttpResponse(HTTP_1_1, status, content); } else { fullHttpResponse = new DefaultFullHttpResponse(HTTP_1_1, status); } for (Map.Entry<String, String> header : recordedHttpResponse.getHeaders().entries()) { fullHttpResponse.headers().add(header.getKey(), header.getValue()); } return fullHttpResponse; } private  NettyHttpResponseMapper(); static FullHttpResponse from(RecordedHttpResponse recordedHttpResponse); }
NettyHttpResponseMapper { public static FullHttpResponse from(RecordedHttpResponse recordedHttpResponse) throws IOException { FullHttpResponse fullHttpResponse; HttpResponseStatus status = HttpResponseStatus.valueOf(recordedHttpResponse.getStatus()); if (recordedHttpResponse.hasHttpBody()) { ByteBuf content = wrappedBuffer(createHttpBodyBytes(recordedHttpResponse)); fullHttpResponse = new DefaultFullHttpResponse(HTTP_1_1, status, content); } else { fullHttpResponse = new DefaultFullHttpResponse(HTTP_1_1, status); } for (Map.Entry<String, String> header : recordedHttpResponse.getHeaders().entries()) { fullHttpResponse.headers().add(header.getKey(), header.getValue()); } return fullHttpResponse; } private  NettyHttpResponseMapper(); static FullHttpResponse from(RecordedHttpResponse recordedHttpResponse); static final String SET_COOKIE; }