Class ServerlessHttpServletResponse

java.lang.Object
org.springframework.cloud.function.serverless.web.ServerlessHttpServletResponse
All Implemented Interfaces:
jakarta.servlet.http.HttpServletResponse, jakarta.servlet.ServletResponse

public class ServerlessHttpServletResponse extends Object implements jakarta.servlet.http.HttpServletResponse
Since:
4.x
Author:
Oleg Zhurakousky
  • Constructor Details

    • ServerlessHttpServletResponse

      public ServerlessHttpServletResponse()
  • Method Details

    • setCharacterEncoding

      public void setCharacterEncoding(String characterEncoding)
      Specified by:
      setCharacterEncoding in interface jakarta.servlet.ServletResponse
    • setCharacterEncoding

      public void setCharacterEncoding(Charset encoding)
      Specified by:
      setCharacterEncoding in interface jakarta.servlet.ServletResponse
    • getCharacterEncoding

      public String getCharacterEncoding()
      Specified by:
      getCharacterEncoding in interface jakarta.servlet.ServletResponse
    • getOutputStream

      public jakarta.servlet.ServletOutputStream getOutputStream()
      Specified by:
      getOutputStream in interface jakarta.servlet.ServletResponse
    • getWriter

      public PrintWriter getWriter() throws UnsupportedEncodingException
      Specified by:
      getWriter in interface jakarta.servlet.ServletResponse
      Throws:
      UnsupportedEncodingException
    • getContentAsByteArray

      public byte[] getContentAsByteArray()
    • getContentAsString

      public String getContentAsString() throws UnsupportedEncodingException
      Get the content of the response body as a String, using the charset specified for the response by the application, either through HttpServletResponse methods or through a charset parameter on the Content-Type. If no charset has been explicitly defined, the
      invalid reference
      default character encoding
      will be used.
      Returns:
      the content as a String
      Throws:
      UnsupportedEncodingException - if the character encoding is not supported
      See Also:
    • getContentAsString

      public String getContentAsString(Charset fallbackCharset) throws UnsupportedEncodingException
      Throws:
      UnsupportedEncodingException
    • setContentLength

      public void setContentLength(int contentLength)
      Specified by:
      setContentLength in interface jakarta.servlet.ServletResponse
    • setContentLengthLong

      public void setContentLengthLong(long len)
      Specified by:
      setContentLengthLong in interface jakarta.servlet.ServletResponse
    • setContentType

      public void setContentType(@Nullable String contentType)
      Specified by:
      setContentType in interface jakarta.servlet.ServletResponse
    • getContentType

      @Nullable public String getContentType()
      Specified by:
      getContentType in interface jakarta.servlet.ServletResponse
    • setBufferSize

      public void setBufferSize(int bufferSize)
      Specified by:
      setBufferSize in interface jakarta.servlet.ServletResponse
    • getBufferSize

      public int getBufferSize()
      Specified by:
      getBufferSize in interface jakarta.servlet.ServletResponse
    • flushBuffer

      public void flushBuffer()
      Specified by:
      flushBuffer in interface jakarta.servlet.ServletResponse
    • resetBuffer

      public void resetBuffer()
      Specified by:
      resetBuffer in interface jakarta.servlet.ServletResponse
    • isCommitted

      public boolean isCommitted()
      Specified by:
      isCommitted in interface jakarta.servlet.ServletResponse
    • reset

      public void reset()
      Specified by:
      reset in interface jakarta.servlet.ServletResponse
    • setLocale

      public void setLocale(@Nullable Locale locale)
      Specified by:
      setLocale in interface jakarta.servlet.ServletResponse
    • getLocale

      public Locale getLocale()
      Specified by:
      getLocale in interface jakarta.servlet.ServletResponse
    • addCookie

      public void addCookie(jakarta.servlet.http.Cookie cookie)
      Specified by:
      addCookie in interface jakarta.servlet.http.HttpServletResponse
    • getCookie

      @Nullable public jakarta.servlet.http.Cookie getCookie(String name)
    • containsHeader

      public boolean containsHeader(String name)
      Specified by:
      containsHeader in interface jakarta.servlet.http.HttpServletResponse
    • getHeaderNames

      public Collection<String> getHeaderNames()
      Return the names of all specified headers as a Set of Strings.

      As of Servlet 3.0, this method is also defined in HttpServletResponse.

      Specified by:
      getHeaderNames in interface jakarta.servlet.http.HttpServletResponse
      Returns:
      the Set of header name Strings, or an empty Set if none
    • setTrailerFields

      public void setTrailerFields(Supplier<Map<String,String>> supplier)
      Specified by:
      setTrailerFields in interface jakarta.servlet.http.HttpServletResponse
    • getTrailerFields

      public Supplier<Map<String,String>> getTrailerFields()
      Specified by:
      getTrailerFields in interface jakarta.servlet.http.HttpServletResponse
    • getHeader

      @Nullable public String getHeader(String name)
      Return the primary value for the given header as a String, if any. Will return the first value in case of multiple values.

      As of Servlet 3.0, this method is also defined in HttpServletResponse. As of Spring 3.1, it returns a stringified value for Servlet 3.0 compatibility. Consider using getHeaderValue(String) for raw Object access.

      Specified by:
      getHeader in interface jakarta.servlet.http.HttpServletResponse
      Parameters:
      name - the name of the header
      Returns:
      the associated header value, or null if none
    • getHeaders

      public List<String> getHeaders(String name)
      Return all values for the given header as a List of Strings.

      As of Servlet 3.0, this method is also defined in HttpServletResponse. As of Spring 3.1, it returns a List of stringified values for Servlet 3.0 compatibility. Consider using getHeaders(String) for raw Object access.

      Specified by:
      getHeaders in interface jakarta.servlet.http.HttpServletResponse
      Parameters:
      name - the name of the header
      Returns:
      the associated header values, or an empty List if none
    • getHeaderValue

      @Nullable public Object getHeaderValue(String name)
      Return the primary value for the given header, if any.

      Will return the first value in case of multiple values.

      Parameters:
      name - the name of the header
      Returns:
      the associated header value, or null if none
    • encodeURL

      public String encodeURL(String url)
      The default implementation returns the given URL String as-is.

      Can be overridden in subclasses, appending a session id or the like.

      Specified by:
      encodeURL in interface jakarta.servlet.http.HttpServletResponse
    • encodeRedirectURL

      public String encodeRedirectURL(String url)
      The default implementation delegates to encodeURL(String), returning the given URL String as-is.

      Can be overridden in subclasses, appending a session id or the like in a redirect-specific fashion. For general URL encoding rules, override the common encodeURL(String) method instead, applying to redirect URLs as well as to general URLs.

      Specified by:
      encodeRedirectURL in interface jakarta.servlet.http.HttpServletResponse
    • sendError

      public void sendError(int status, String errorMessage) throws IOException
      Specified by:
      sendError in interface jakarta.servlet.http.HttpServletResponse
      Throws:
      IOException
    • sendError

      public void sendError(int status) throws IOException
      Specified by:
      sendError in interface jakarta.servlet.http.HttpServletResponse
      Throws:
      IOException
    • sendRedirect

      public void sendRedirect(String url) throws IOException
      Specified by:
      sendRedirect in interface jakarta.servlet.http.HttpServletResponse
      Throws:
      IOException
    • sendRedirect

      public void sendRedirect(String location, int sc, boolean clearBuffer) throws IOException
      Specified by:
      sendRedirect in interface jakarta.servlet.http.HttpServletResponse
      Throws:
      IOException
    • getRedirectedUrl

      @Nullable public String getRedirectedUrl()
    • setDateHeader

      public void setDateHeader(String name, long value)
      Specified by:
      setDateHeader in interface jakarta.servlet.http.HttpServletResponse
    • addDateHeader

      public void addDateHeader(String name, long value)
      Specified by:
      addDateHeader in interface jakarta.servlet.http.HttpServletResponse
    • setHeader

      public void setHeader(String name, @Nullable String value)
      Specified by:
      setHeader in interface jakarta.servlet.http.HttpServletResponse
    • addHeader

      public void addHeader(String name, @Nullable String value)
      Specified by:
      addHeader in interface jakarta.servlet.http.HttpServletResponse
    • setIntHeader

      public void setIntHeader(String name, int value)
      Specified by:
      setIntHeader in interface jakarta.servlet.http.HttpServletResponse
    • addIntHeader

      public void addIntHeader(String name, int value)
      Specified by:
      addIntHeader in interface jakarta.servlet.http.HttpServletResponse
    • setStatus

      public void setStatus(int status)
      Specified by:
      setStatus in interface jakarta.servlet.http.HttpServletResponse
    • getStatus

      public int getStatus()
      Specified by:
      getStatus in interface jakarta.servlet.http.HttpServletResponse
    • getErrorMessage

      @Nullable public String getErrorMessage()