Package org.apache.hc.core5.http.message
Class BufferedHeader
- java.lang.Object
-
- org.apache.hc.core5.http.message.BufferedHeader
-
- All Implemented Interfaces:
java.io.Serializable,FormattedHeader,Header,NameValuePair
public class BufferedHeader extends java.lang.Object implements FormattedHeader, java.io.Serializable
This class represents a raw HTTP header whose content is parsed 'on demand' only when the header value needs to be consumed.- Since:
- 4.0
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private CharArrayBufferbufferThe buffer containing the entire header line.private java.lang.StringnameHeader name.private static longserialVersionUIDprivate intvaluePosThe beginning of the header value in the buffer
-
Constructor Summary
Constructors Constructor Description BufferedHeader(CharArrayBuffer buffer)Creates a new header from a buffer.BufferedHeader(CharArrayBuffer buffer, boolean strict)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static BufferedHeadercreate(CharArrayBuffer buffer)CharArrayBuffergetBuffer()Obtains the buffer with the formatted header.java.lang.StringgetName()Gets the name of this pair.java.lang.StringgetValue()Gets the value of this pair.intgetValuePos()Obtains the start of the header value in thebuffer.booleanisSensitive()Returnstrueif the header should be considered sensitive.java.lang.StringtoString()
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
name
private final java.lang.String name
Header name.
-
buffer
private final CharArrayBuffer buffer
The buffer containing the entire header line.
-
valuePos
private final int valuePos
The beginning of the header value in the buffer
-
-
Constructor Detail
-
BufferedHeader
public BufferedHeader(CharArrayBuffer buffer) throws ParseException
Creates a new header from a buffer. The name of the header will be parsed immediately, the value only if it is accessed.- Parameters:
buffer- the buffer containing the header to represent- Throws:
ParseException- in case of a parse error
-
BufferedHeader
BufferedHeader(CharArrayBuffer buffer, boolean strict) throws ParseException
- Throws:
ParseException
-
-
Method Detail
-
create
public static BufferedHeader create(CharArrayBuffer buffer)
- Since:
- 5.0
-
getName
public java.lang.String getName()
Description copied from interface:NameValuePairGets the name of this pair.- Specified by:
getNamein interfaceNameValuePair- Returns:
- the name of this pair, never
null.
-
getValue
public java.lang.String getValue()
Description copied from interface:NameValuePairGets the value of this pair.- Specified by:
getValuein interfaceNameValuePair- Returns:
- the value of this pair, may be
null.
-
isSensitive
public boolean isSensitive()
Description copied from interface:HeaderReturnstrueif the header should be considered sensitive.Some encoding schemes such as HPACK impose restrictions on encoded representation of sensitive headers.
- Specified by:
isSensitivein interfaceHeader- Returns:
trueif the header should be considered sensitive.
-
getValuePos
public int getValuePos()
Description copied from interface:FormattedHeaderObtains the start of the header value in thebuffer. By accessing the value in the buffer, creation of a temporary string can be avoided.- Specified by:
getValuePosin interfaceFormattedHeader- Returns:
- index of the first character of the header value
in the buffer returned by
getBuffer.
-
getBuffer
public CharArrayBuffer getBuffer()
Description copied from interface:FormattedHeaderObtains the buffer with the formatted header. The returned buffer MUST NOT be modified.- Specified by:
getBufferin interfaceFormattedHeader- Returns:
- the formatted header, in a buffer that must not be modified
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-