private static RawHttpHeaders createDateHeader() { return RawHttpHeaders.newBuilderSkippingValidation() .with("Date", RFC_1123_DATE_TIME.format(ZonedDateTime.now(ZoneOffset.UTC))) .build(); }
private RawHttpHeaders.Builder buildHeaders( InputStream stream, BiFunction<String, Integer, RuntimeException> createError) throws IOException { RawHttpHeaders.Builder builder = RawHttpHeaders.newBuilderSkippingValidation(); int lineNumber = 1; Map.Entry<String, String> header; while ((header = parseHeaderField(stream, lineNumber, createError)) != null) { builder.with(header.getKey(), header.getValue()); lineNumber++; } return builder; }
private static RawHttpHeaders createDateHeader() { return RawHttpHeaders.newBuilderSkippingValidation() .with("Date", RFC_1123_DATE_TIME.format(ZonedDateTime.now(ZoneOffset.UTC))) .build(); }
private RawHttpHeaders.Builder buildHeaders( InputStream stream, BiFunction<String, Integer, RuntimeException> createError) throws IOException { RawHttpHeaders.Builder builder = RawHttpHeaders.newBuilderSkippingValidation(); int lineNumber = 1; Map.Entry<String, String> header; while ((header = parseHeaderField(stream, lineNumber, createError)) != null) { builder.with(header.getKey(), header.getValue()); lineNumber++; } return builder; }
/** * Create a new set of headers, adding/replacing the provided headers into this instance. * <p> * Multi-valued headers present in both this and the provided headers are not merged. The provided headers * are guaranteed to be present and have the same values in the returned instance. * * @param headers to add or replace on this. * @return new set of headers containing both this instance's values as well as the provided values */ public RawHttpHeaders and(RawHttpHeaders headers) { Builder builder = RawHttpHeaders.newBuilderSkippingValidation(this); Set<String> visitedNames = new HashSet<>(headers.headerNames.size()); headers.forEach((name, value) -> { String key = toUppercaseAscii(name); boolean isNewKey = visitedNames.add(key); if (isNewKey) { builder.overwrite(name, value); } else { builder.with(name, value); } }); return builder.build(); }
/** * Create a new set of headers, adding/replacing the provided headers into this instance. * <p> * Multi-valued headers present in both this and the provided headers are not merged. The provided headers * are guaranteed to be present and have the same values in the returned instance. * * @param headers to add or replace on this. * @return new set of headers containing both this instance's values as well as the provided values */ public RawHttpHeaders and(RawHttpHeaders headers) { Builder builder = RawHttpHeaders.newBuilderSkippingValidation(this); Set<String> visitedNames = new HashSet<>(headers.headerNames.size()); headers.forEach((name, value) -> { String key = toUppercaseAscii(name); boolean isNewKey = visitedNames.add(key); if (isNewKey) { builder.overwrite(name, value); } else { builder.with(name, value); } }); return builder.build(); }