001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.juneau.rest.client; 018 019import static org.apache.juneau.commons.utils.Shorts.*; 020 021 022/** 023 * An HTTP header name/value pair as seen by the transport layer. 024 * 025 * <p> 026 * Unlike {@link org.apache.juneau.http.HttpHeader}, this is a fully-resolved, eagerly-evaluated value; 027 * suppliers have already been invoked and {@code null}-valued headers have already been filtered out before 028 * a {@link TransportRequest} is constructed. 029 * 030 * @param name The header name. Never {@code null}. 031 * @param value The header value. Never {@code null}. 032 * 033 * @since 9.2.1 034 */ 035public record TransportHeader(String name, String value) { 036 037 /** 038 * Compact canonical constructor — validates that neither field is {@code null}. 039 * 040 * @param name The header name. Must not be <jk>null</jk>. 041 * @param value The header value. Must not be <jk>null</jk>. 042 */ 043 public TransportHeader { 044 reqnn("name", name); 045 reqnn("value", value); 046 } 047 048 /** 049 * Factory method. 050 * 051 * @param name The header name. Must not be <jk>null</jk>. 052 * @param value The header value. Must not be <jk>null</jk>. 053 * @return A new instance. Never <jk>null</jk>. 054 */ 055 public static TransportHeader of(String name, String value) { 056 return new TransportHeader(name, value); 057 } 058}