JavaScript is disabled on your browser.
Skip navigation links
org.htmlunit.util

Class WebResponseWrapper

  • All Implemented Interfaces:
    Serializable


    public class WebResponseWrapper
    extends WebResponse 
    Provides a convenient implementation of the WebResponse interface that can be subclassed by developers wishing to adapt a particular WebResponse. This class implements the Wrapper or Decorator pattern. Methods default to calling through to the wrapped web response object.
    Author:
    Marc Guillemot, Ahmed Ashour, Ronald Brill, Atsushi Nakagawa, Lai Quang Duong
    See Also:
    Serialized Form
    • Constructor Detail

    • Method Detail

      • getContentLength

        public long getContentLength()
        Returns length of the content data. The default behavior of this method is to return getContentLength() on the wrapped webResponse object.
        Overrides:
        getContentLength in class WebResponse
        Returns:
        the length
      • getContentAsStream

        public InputStream getContentAsStream()
         throws IOException 
        Returns the response content as an input stream. The default behavior of this method is to return getContentAsStream() on the wrapped webResponse object.
        Overrides:
        getContentAsStream in class WebResponse
        Returns:
        the response content as an input stream
        Throws:
        IOException - in case of IOProblems
      • getContentAsString

        public String getContentAsString()
        Returns the response content as a string, using the charset/encoding specified in the server response. The default behavior of this method is to return getContentAsString() on the wrapped webResponse object.
        Overrides:
        getContentAsString in class WebResponse
        Returns:
        the response content as a string, using the charset/encoding specified in the server response or null if the content retrieval was failing
      • getContentAsString

        public String getContentAsString(Charset encoding)
        Returns the response content as a string, using the specified charset, rather than the charset/encoding specified in the server response. If there is a bom header the charset parameter will be overwritten by the bom. The default behavior of this method is to return getContentAsString(Charset) on the wrapped webResponse object.
        Overrides:
        getContentAsString in class WebResponse
        Parameters:
        encoding - the charset/encoding to use to convert the response content into a string
        Returns:
        the response content as a string or null if the content retrieval was failing
      • getHeaderContentCharset

        public Charset getHeaderContentCharset()
        Returns the content charset specified explicitly in the Content-Type header or null if none was specified. The default behavior of this method is to return getHeaderContentCharset() on the wrapped webResponse object.
        Overrides:
        getHeaderContentCharset in class WebResponse
        Returns:
        the content charset specified header or null if none was specified
      • getContentCharset

        public Charset getContentCharset()
        Returns the content charset for this response, even if no charset was specified explicitly.

        This method always returns a valid charset. This method first checks the Content-Type header or in the content BOM for viable charset. If not found, it attempts to determine the charset based on the type of the content. As a last resort, this method returns the value of WebRequest.getDefaultResponseContentCharset() which is StandardCharsets.UTF_8 by default. The default behavior of this method is to return getContentCharset() on the wrapped webResponse object.

        Overrides:
        getContentCharset in class WebResponse
        Returns:
        the content charset for this response
      • getContentType

        public String getContentType()
        Returns the content type returned from the server, e.g. "text/html". The default behavior of this method is to return getContentType() on the wrapped webResponse object.
        Overrides:
        getContentType in class WebResponse
        Returns:
        the content type returned from the server, e.g. "text/html"
      • getLoadTime

        public long getLoadTime()
        Returns the time it took to load this web response, in milliseconds. The default behavior of this method is to return getLoadTime() on the wrapped webResponse object.
        Overrides:
        getLoadTime in class WebResponse
        Returns:
        the time it took to load this web response, in milliseconds
      • getResponseHeaderValue

        public String getResponseHeaderValue(String headerName)
        Returns the value of the specified response header. The default behavior of this method is to return getResponseHeaderValue() on the wrapped webResponse object.
        Overrides:
        getResponseHeaderValue in class WebResponse
        Parameters:
        headerName - the name of the header whose value is to be returned
        Returns:
        the header value, null if no response header exists with this name
      • getStatusCode

        public int getStatusCode()
        Returns the status code that was returned by the server. The default behavior of this method is to return getStatusCode() on the wrapped webResponse object.
        Overrides:
        getStatusCode in class WebResponse
        Returns:
        the status code that was returned by the server
      • getStatusMessage

        public String getStatusMessage()
        Returns the status message that was returned from the server. The default behavior of this method is to return getStatusMessage() on the wrapped webResponse object.
        Overrides:
        getStatusMessage in class WebResponse
        Returns:
        the status message that was returned from the server
      • getWebRequest

        public WebRequest getWebRequest()
        Returns the request used to load this response. The default behavior of this method is to return getWebRequest() on the wrapped webResponse object.
        Overrides:
        getWebRequest in class WebResponse
        Returns:
        the request used to load this response
      • cleanUp

        public void cleanUp()
        Clean up the response data. The default behavior of this method is to call cleanUp() on the wrapped webResponse object.
        Overrides:
        cleanUp in class WebResponse
      • isSuccess

        public boolean isSuccess()
        Overrides:
        isSuccess in class WebResponse
        Returns:
        true if the 2xx
Skip navigation links

Copyright © 2002–2025 Gargoyle Software Inc.. All rights reserved.

AltStyle によって変換されたページ (->オリジナル) /