public class

ObservantResponseWrapper

extends HttpServletResponseWrapper
java.lang.Object
   ↳ javax.servlet.ServletResponseWrapper
     ↳ javax.servlet.http.HttpServletResponseWrapper
       ↳ com.atlassian.jira.util.http.response.ObservantResponseWrapper

Class Overview

This HttpServletResponseWrapper can capture the HTTP response code and also to know the length of the data output.

THREAD SAFETY - One of these must be constructed on each HTTP request/response and hence only one thread may write to it at the one time. This suits the whole servlet engine idea,

Summary

[Expand]
Inherited Constants
From interface javax.servlet.http.HttpServletResponse
Public Constructors
ObservantResponseWrapper(HttpServletResponse httpServletResponse)
Public Methods
long getContentLen()
Returns the length of the content that has been sent back via this HttpServletResponseWrapper.
ServletOutputStream getOutputStream()
Overridden to capture output content length
int getStatus()
PrintWriter getWriter()
Overridden to capture output content length
void sendError(int sc, String s)
Overridden to capture HTTP status codes
void sendError(int sc)
Overridden to capture HTTP status codes
void setStatus(int sc, String s)
Overridden to capture HTTP status codes
void setStatus(int sc)
Overridden to capture HTTP status codes
[Expand]
Inherited Methods
From class javax.servlet.http.HttpServletResponseWrapper
From class javax.servlet.ServletResponseWrapper
From class java.lang.Object
From interface javax.servlet.ServletResponse
From interface javax.servlet.http.HttpServletResponse

Public Constructors

public ObservantResponseWrapper (HttpServletResponse httpServletResponse)

Public Methods

public long getContentLen ()

Returns the length of the content that has been sent back via this HttpServletResponseWrapper.

This is a count in character OR bytes, depending on form of output was used. Let em explain! If the web response uses the getOutputStream() method, then the content length will be a count of bytes. If they use the getWriter() method, then it will be a count of characters.

We dont want to get into the game of working out how a set of Unicode characters translate into a series of bytes. Its expensive and the point of this code is to be as cheap as possible.

Returns
  • the length of the content that has been sent back via this HttpServletResponseWrapper in bytes or characters depending on whcih output mechanism is used.

public ServletOutputStream getOutputStream ()

Overridden to capture output content length

Throws
IOException

public int getStatus ()

Returns
  • the HTTP status code set on this HttpServletResponseWrapper

public PrintWriter getWriter ()

Overridden to capture output content length

Throws
IOException

public void sendError (int sc, String s)

Overridden to capture HTTP status codes

Throws
IOException

public void sendError (int sc)

Overridden to capture HTTP status codes

Throws
IOException

public void setStatus (int sc, String s)

Overridden to capture HTTP status codes

public void setStatus (int sc)

Overridden to capture HTTP status codes