@Test public void testVisitCustomHeaders() { TestFileLikePart fileLikePart = new TestFileLikePart(null); fileLikePart.addCustomHeader("custom-header", "header-value"); try (TestMultipartPart multipartPart = new TestMultipartPart(fileLikePart, new byte[0])) { CounterPartVisitor counterVisitor = new CounterPartVisitor(); multipartPart.visitCustomHeaders(counterVisitor); assertEquals(counterVisitor.getCount(), 29, "CounterPartVisitor count for visitCustomHeaders should include the length of the custom headers"); } }
protected void visitCustomHeaders(PartVisitor visitor) { if (isNonEmpty(part.getCustomHeaders())) { for (Param param : part.getCustomHeaders()) { visitor.withBytes(CRLF_BYTES); visitor.withBytes(param.getName().getBytes(US_ASCII)); visitor.withBytes(HEADER_NAME_VALUE_SEPARATOR_BYTES); visitor.withBytes(param.getValue().getBytes(US_ASCII)); } } }
MultipartPart implements Closeable { protected void visitCustomHeaders(PartVisitor visitor) { if (isNonEmpty(part.getCustomHeaders())) { for (Param param : part.getCustomHeaders()) { visitor.withBytes(CRLF_BYTES); visitor.withBytes(param.getName().getBytes(US_ASCII)); visitor.withBytes(HEADER_NAME_VALUE_SEPARATOR_BYTES); visitor.withBytes(param.getValue().getBytes(US_ASCII)); } } } }
MultipartPart implements Closeable { protected void visitCustomHeaders(PartVisitor visitor) { if (isNonEmpty(part.getCustomHeaders())) { for (Param param : part.getCustomHeaders()) { visitor.withBytes(CRLF_BYTES); visitor.withBytes(param.getName().getBytes(US_ASCII)); visitor.withBytes(HEADER_NAME_VALUE_SEPARATOR_BYTES); visitor.withBytes(param.getValue().getBytes(US_ASCII)); } } } MultipartPart(T part, byte[] boundary); }
MultipartPart implements Closeable { protected void visitCustomHeaders(PartVisitor visitor) { if (isNonEmpty(part.getCustomHeaders())) { for (Param param : part.getCustomHeaders()) { visitor.withBytes(CRLF_BYTES); visitor.withBytes(param.getName().getBytes(US_ASCII)); visitor.withBytes(HEADER_NAME_VALUE_SEPARATOR_BYTES); visitor.withBytes(param.getValue().getBytes(US_ASCII)); } } } MultipartPart(T part, byte[] boundary); long length(); MultipartState getState(); boolean isTargetSlow(); long transferTo(ByteBuf target); long transferTo(WritableByteChannel target); @Override void close(); }
MultipartPart implements Closeable { protected void visitCustomHeaders(PartVisitor visitor) { if (isNonEmpty(part.getCustomHeaders())) { for (Param param : part.getCustomHeaders()) { visitor.withBytes(CRLF_BYTES); visitor.withBytes(param.getName().getBytes(US_ASCII)); visitor.withBytes(HEADER_NAME_VALUE_SEPARATOR_BYTES); visitor.withBytes(param.getValue().getBytes(US_ASCII)); } } } MultipartPart(T part, byte[] boundary); long length(); MultipartState getState(); boolean isTargetSlow(); long transferTo(ByteBuf target); long transferTo(WritableByteChannel target); @Override void close();  }