Class HttpHeader

    • Field Detail

      • isCommitted

        protected boolean isCommitted
      • protocolC

        protected final DataChunk protocolC
      • parsedProtocol

        protected Protocol parsedProtocol
      • isChunked

        protected boolean isChunked
      • contentLength

        protected long contentLength
      • isExpectContent

        protected boolean isExpectContent
      • isSkipRemainder

        protected boolean isSkipRemainder
      • isContentBroken

        protected boolean isContentBroken
        true if HTTP message payload is broken due to inappropriate Transfer-Encoding or Content-Encoding settings.
      • secure

        protected boolean secure
    • Constructor Detail

      • HttpHeader

        public HttpHeader()
      • HttpHeader

        protected HttpHeader​(MimeHeaders headers)
    • Method Detail

      • getAttributes

        public org.glassfish.grizzly.attributes.AttributeHolder getAttributes()
        Specified by:
        getAttributes in interface org.glassfish.grizzly.attributes.AttributeStorage
      • isRequest

        public abstract boolean isRequest()
        Returns true, if the current HttpHeader represent HTTP request message, or false otherwise.
        Returns:
        true, if the current HttpHeader represent HTTP request message, or false otherwise.
      • isHeader

        public final boolean isHeader()
        Returns true.
        Specified by:
        isHeader in class HttpPacket
        Returns:
        true.
      • getHttpHeader

        public HttpHeader getHttpHeader()
        Returns this HttpHeader object.
        Specified by:
        getHttpHeader in class HttpPacket
        Returns:
        this HttpHeader object.
      • getProcessingState

        public abstract ProcessingState getProcessingState()
      • getParsingState

        protected HttpPacketParsing getParsingState()
        Returns:
        the parsing state of this HTTP header, or null if the message is complete or shouldn't be parsed at all
      • addContentEncoding

        protected void addContentEncoding​(ContentEncoding contentEncoding)
      • getContentEncodings

        protected List<ContentEncoding> getContentEncodings​(boolean isModifiable)
      • isContentEncodingsSelected

        protected final boolean isContentEncodingsSelected()
      • setContentEncodingsSelected

        protected final void setContentEncodingsSelected​(boolean isContentEncodingsSelected)
      • getTransferEncoding

        public TransferEncoding getTransferEncoding()
        Get the TransferEncoding, responsible for the parsing/serialization of the HTTP message content
        Returns:
        the TransferEncoding, responsible for the parsing/serialization of the HTTP message content
      • setTransferEncoding

        protected void setTransferEncoding​(TransferEncoding transferEncoding)
        Set the TransferEncoding, responsible for the parsing/serialization of the HTTP message content.
        Parameters:
        transferEncoding - the TransferEncoding, responsible for the parsing/serialization of the HTTP message content.
      • isChunked

        public boolean isChunked()
        Returns true, if this HttpPacket content will be transferred in chunking mode, or false if case of fixed-length message.
        Returns:
        true, if this HttpPacket content will be transferred in chunking mode, or false if case of fixed-length message.
      • setChunked

        public void setChunked​(boolean isChunked)
        Set true, if this HttpPacket content will be transferred in chunking mode, or false if case of fixed-length message. NOTE: If the protocol version of this header is 1.0 or older, chunking will be disabled regardless of the value passed.
        Parameters:
        isChunked - true, if this HttpPacket content will be transferred in chunking mode, or false if case of fixed-length message.
      • isExpectContent

        public boolean isExpectContent()
        Returns true, if HTTP message, represented by this header still expects additional content basing either on content-length or chunking information. false is returned if content no additional content data is expected. Note: this method could be used only when we parse the HTTP message
        Returns:
        true, if HTTP message, represented by this header still expects additional content basing either on content-length or chunking information. false is returned if content no additional content data is expected.
      • setExpectContent

        public void setExpectContent​(boolean isExpectContent)
      • isSkipRemainder

        public boolean isSkipRemainder()
        Returns true, if either application or HTTP core part is not interested in parsing the rest of this HTTP message content and waits for the next HTTP message to come on this Connection. Otherwise returns false.
        Returns:
        true, if either application or HTTP core part is not interested in parsing the rest of this HTTP message content and waits for the next HTTP message to come on this Connection. Otherwise returns false.
      • setSkipRemainder

        public void setSkipRemainder​(boolean isSkipRemainder)
        Set flag, which is set to true, means that we're not interested in parsing the rest of this HTTP message content and wait for the next HTTP message to come on this Connection.
        Parameters:
        isSkipRemainder - true means that we're not interested in parsing the rest of this HTTP message content and wait for the next HTTP message to come on this Connection.
      • isContentBroken

        public boolean isContentBroken()
        Returns true, if HTTP packet payload was detected as broken due to unexpected error occurred during Transfer-Encoding or Content-Encoding processing. Otherwise returns false.
        Returns:
        true, if HTTP packet payload was detected as broken due to unexpected error occurred during Transfer-Encoding or Content-Encoding processing. Otherwise returns false.
      • setContentBroken

        public void setContentBroken​(boolean isBroken)
        Set flag, which is set to true, means that HTTP packet payload was detected as broken due to unexpected error occurred during Transfer-Encoding or Content-Encoding processing.
        Parameters:
        isBroken - true, means that HTTP packet payload was detected as broken due to unexpected error occurred during Transfer-Encoding or Content-Encoding processing.
      • getUpgrade

        public final String getUpgrade()
        Returns:
        the "Upgrade" header value.
      • getUpgradeDC

        public DataChunk getUpgradeDC()
        Returns:
        the "Upgrade" header value.
      • setUpgrade

        public final void setUpgrade​(String upgrade)
        Sets the "Upgrade" header value
        Parameters:
        upgrade -
      • isUpgrade

        public boolean isUpgrade()
        Returns:
        true if this header represents an HTTP upgrade, otherwise false.
        Since:
        2.3.29
      • makeUpgradeHeader

        protected void makeUpgradeHeader()
        Propagate the "Upgrade" value to headers.
      • isIgnoreContentModifiers

        public boolean isIgnoreContentModifiers()
        Returns:
        true if parser has to ignore "Transfer-Encoding" and "Content-Encoding" headers and act as none of them were specified.
      • setIgnoreContentModifiers

        public void setIgnoreContentModifiers​(boolean isIgnoreContentModifiers)
        Set true if parser has to ignore "Transfer-Encoding" and "Content-Encoding" headers and act as none of them were specified.
        Parameters:
        isIgnoreContentModifiers -
      • makeContentLengthHeader

        protected void makeContentLengthHeader​(long defaultLength)
        Makes sure content-length header is present.
        Parameters:
        defaultLength - default content-length value.
      • getContentLength

        public long getContentLength()
        Get the content-length of this HttpPacket. Applicable only in case of fixed-length HTTP message.
        Returns:
        the content-length of this HttpPacket. Applicable only in case of fixed-length HTTP message.
      • setContentLength

        public void setContentLength​(int len)
        Set the length of this HTTP message.
        Parameters:
        len - the length of this HTTP message.
      • setContentLengthLong

        public void setContentLengthLong​(long contentLength)
        Set the content-length of this HttpPacket. Applicable only in case of fixed-length HTTP message.
        Parameters:
        contentLength - the content-length of this HttpPacket. Applicable only in case of fixed-length HTTP message.
      • isCommitted

        public boolean isCommitted()
        Is this HttpHeader written? true, if this HttpHeader has been already serialized, and only HttpContent messages might be serialized for this HttpPacket.
        Returns:
        true, if this HttpHeader has been already serialized, and only HttpContent messages might be serialized for this HttpPacket.
      • setCommitted

        public void setCommitted​(boolean isCommitted)
        Is this HttpHeader written? true, if this HttpHeader has been already serialized, and only HttpContent messages might be serialized for this HttpPacket.
        Parameters:
        isCommitted - true, if this HttpHeader has been already serialized, and only HttpContent messages might be serialized for this HttpPacket.
      • makeTransferEncodingHeader

        protected void makeTransferEncodingHeader​(String defaultValue)
        Makes sure transfer-encoding header is present.
        Parameters:
        defaultValue - default transfer-encoding value.
      • extractContentEncoding

        protected void extractContentEncoding​(DataChunk value)
        Obtain content-encoding value and mark it as serialized.
        Parameters:
        value - container for the content-type value.
      • getCharacterEncoding

        public String getCharacterEncoding()
        Returns:
        the character encoding of this HTTP message.
      • setCharacterEncoding

        public void setCharacterEncoding​(String charset)
        Set the character encoding of this HTTP message.
        Parameters:
        charset - the encoding.
      • isChunkingAllowed

        public boolean isChunkingAllowed()
        Return true if chunking is allowed for this header.
        Returns:
        true if chunking is allowed for this header.
        Since:
        3.0
      • setChunkingAllowed

        public void setChunkingAllowed​(boolean chunkingAllowed)
        Indicate whether or not chunking may be used by this header.
        Parameters:
        chunkingAllowed - true if chunked transfer-encoding is allowed, otherwise returns false.
        Since:
        3.0
      • isContentTypeSet

        public boolean isContentTypeSet()
        Returns:
        true if a content type has been set.
      • getContentType

        public String getContentType()
        Returns:
        the content type of this HTTP message.
      • setContentType

        public void setContentType​(String contentType)
        Sets the content type. This method must preserve any charset that may already have been set via a call to request/response.setContentType(), request/response.setLocale(), or request/response.setCharacterEncoding().
        Parameters:
        contentType - the content type
      • setContentType

        public void setContentType​(ContentType contentType)
        Sets the content type. This method must preserve any charset that may already have been set via a call to request/response.setContentType(), request/response.setLocale(), or request/response.setCharacterEncoding(). This method copies the passed contentType state into this ContentType.
        Parameters:
        contentType - the content type
      • getHeader

        public String getHeader​(String name)
        Get the value, of the specific HTTP mime header.
        Specified by:
        getHeader in interface MimeHeadersPacket
        Parameters:
        name - the mime header name
        Returns:
        the value, of the specific HTTP mime header
      • getHeader

        public String getHeader​(Header header)
        Get the value, of the specific HTTP mime header.
        Specified by:
        getHeader in interface MimeHeadersPacket
        Parameters:
        header - the mime Header
        Returns:
        the value, of the specific HTTP mime header
      • setHeader

        public void setHeader​(String name,
                              String value)
        Set the value, of the specific HTTP mime header.
        Specified by:
        setHeader in interface MimeHeadersPacket
        Parameters:
        name - the mime header name
        value - the mime header value
      • setHeader

        public void setHeader​(String name,
                              HeaderValue value)
        Set the value, of the specific HTTP mime header.
        Specified by:
        setHeader in interface MimeHeadersPacket
        Parameters:
        name - the mime header name
        value - the mime header value
      • setHeader

        public void setHeader​(Header header,
                              String value)
        Set the value, of the specific HTTP mime header.
        Specified by:
        setHeader in interface MimeHeadersPacket
        Parameters:
        header - the mime Header
        value - the mime header value
      • setHeader

        public void setHeader​(Header header,
                              HeaderValue value)
        Set the value, of the specific HTTP mime header.
        Specified by:
        setHeader in interface MimeHeadersPacket
        Parameters:
        header - the mime Header
        value - the mime header value
      • addHeader

        public void addHeader​(String name,
                              String value)
        Add the HTTP mime header.
        Specified by:
        addHeader in interface MimeHeadersPacket
        Parameters:
        name - the mime header name
        value - the mime header value
      • addHeader

        public void addHeader​(String name,
                              HeaderValue value)
        Add the HTTP mime header.
        Specified by:
        addHeader in interface MimeHeadersPacket
        Parameters:
        name - the mime header name
        value - the mime header value
      • containsHeader

        public boolean containsHeader​(String name)
        Returns true, if the mime header with the specific name is present among the HttpHeader mime headers, or false otherwise.
        Specified by:
        containsHeader in interface MimeHeadersPacket
        Parameters:
        name - the mime header name
        Returns:
        true, if the mime header with the specific name is present among the HttpHeader mime headers, or false otherwise
      • containsHeader

        public boolean containsHeader​(Header header)
        Returns true, if the mime Header is present among the HttpHeader mime headers, otherwise returns false.
        Specified by:
        containsHeader in interface MimeHeadersPacket
        Parameters:
        header - the mime Header
        Returns:
        true, if the mime Header is present among the HttpHeader mime headers, otherwise returns false
      • getProtocolDC

        public DataChunk getProtocolDC()
        Get the HTTP message protocol version as DataChunk (avoiding creation of a String object). The result format is "HTTP/1.x".
        Returns:
        the HTTP message protocol version as DataChunk (avoiding creation of a String object). The result format is "HTTP/1.x".
      • getProtocolString

        public String getProtocolString()
        Get the HTTP message protocol version. The result format is "HTTP/1.x".
        Returns:
        the HTTP message protocol version. The result format is "HTTP/1.x".
      • getProtocol

        public Protocol getProtocol()
        Get HTTP protocol version.
        Returns:
        Protocol.
      • setProtocol

        public void setProtocol​(Protocol protocol)
        Set the HTTP message protocol version.
        Parameters:
        protocol - Protocol
      • isSecure

        public boolean isSecure()
        Returns:
        true if this HTTP message is being transmitted in a secure fashion, otherwise returns false.
      • setSecure

        public void setSecure​(boolean secure)
        Sets the secure status of this HTTP message.
        Parameters:
        secure - true if secure, otherwise false.
      • reset

        protected void reset()
        Reset the internal state.
      • recycle

        public void recycle()
        Specified by:
        recycle in interface org.glassfish.grizzly.Cacheable
      • getTempHeaderEncodingBuffer

        public byte[] getTempHeaderEncodingBuffer()
      • flushSpecialHeaders

        protected void flushSpecialHeaders()
        Flush internal fields for special header names to the headers map.