Class ProxyResponseImpl

  • All Implemented Interfaces:
    ProxyResponse

    public final class ProxyResponseImpl
    extends java.lang.Object
    implements ProxyResponse
    Represents an HTTP response from a proxy.
    See Also:
    RFC2616
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addContent​(java.nio.ByteBuffer content)
      Adds additional content to the HTTP response's body.
      static ProxyResponse create​(java.nio.ByteBuffer buffer)
      Create a proxy response from a given buffer.
      java.nio.ByteBuffer getContents()
      Gets the HTTP response body.
      java.lang.String getError()
      Gets the HTTP response body as an error.
      java.util.Map<java.lang.String,​java.util.List<java.lang.String>> getHeaders()
      Gets the headers for the HTTP response.
      HttpStatusLine getStatus()
      Gets the HTTP status line.
      boolean isMissingContent()
      Gets whether or not the HTTP response is complete.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • create

        public static ProxyResponse create​(java.nio.ByteBuffer buffer)
        Create a proxy response from a given buffer. Assumes that the buffer has been flipped.
        Parameters:
        buffer - Buffer which could parse to a proxy response.
        Returns:
        A new instance of ProxyResponseImpl representing the given buffer.
        Throws:
        java.lang.IllegalArgumentException - if buffer have no content to read.
      • getHeaders

        public java.util.Map<java.lang.String,​java.util.List<java.lang.String>> getHeaders()
        Gets the headers for the HTTP response.
        Specified by:
        getHeaders in interface ProxyResponse
        Returns:
        The headers for the HTTP response.
      • getContents

        public java.nio.ByteBuffer getContents()
        Gets the HTTP response body.
        Specified by:
        getContents in interface ProxyResponse
        Returns:
        The HTTP response body.
      • getError

        public java.lang.String getError()
        Gets the HTTP response body as an error.
        Specified by:
        getError in interface ProxyResponse
        Returns:
        If there is no HTTP response body, an empty string is returned.
      • isMissingContent

        public boolean isMissingContent()
        Gets whether or not the HTTP response is complete. An HTTP response is complete when the HTTP header and body are received.
        Specified by:
        isMissingContent in interface ProxyResponse
        Returns:
        true if the HTTP response is complete, and false otherwise.
      • addContent

        public void addContent​(java.nio.ByteBuffer content)
        Adds additional content to the HTTP response's body. Assumes that the content has been flipped.
        Specified by:
        addContent in interface ProxyResponse
        Parameters:
        content - Content to add to the body of the HTTP response.
        Throws:
        java.lang.NullPointerException - if content is null.
        java.lang.IllegalArgumentException - if content have no content to read.