Package org.sonar.api.server.http
Interface HttpResponse
-
public interface HttpResponse
Framework-agnostic definition of an HTTP response.- Since:
- 9.16
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addCookie(Cookie cookie)
Adds the specified cookie to the response.void
addHeader(java.lang.String name, java.lang.String value)
Adds a response header with the given name and value.java.lang.String
getHeader(java.lang.String name)
Gets the value of the response header with the given name.java.util.Collection<java.lang.String>
getHeaders(java.lang.String name)
Gets the values of the response header with the given name.java.io.OutputStream
getOutputStream()
Returns aOutputStream
suitable for writing binary data in the response.int
getStatus()
Gets the current status code of this response.java.io.PrintWriter
getWriter()
Returns aPrintWriter
object that can send character text to the client.void
sendRedirect(java.lang.String location)
Sends a temporary redirect response to the client using the specified redirect location URL and clears the buffer.void
setCharacterEncoding(java.lang.String charset)
Sets the character encoding (MIME charset) of the response being sent to the client, for example, to UTF-8.void
setContentType(java.lang.String contentType)
Sets the content type of the response being sent to the client, if the response has not been committed yet.void
setHeader(java.lang.String name, java.lang.String value)
Sets a response header with the given name and value.void
setStatus(int sc)
Sets the status code for this response.
-
-
-
Method Detail
-
addHeader
void addHeader(java.lang.String name, java.lang.String value)
Adds a response header with the given name and value. This method allows response headers to have multiple values.
-
getHeader
java.lang.String getHeader(java.lang.String name)
Gets the value of the response header with the given name. If a response header with the given name exists and contains multiple values, the value that was added first will be returned.
-
getHeaders
java.util.Collection<java.lang.String> getHeaders(java.lang.String name)
Gets the values of the response header with the given name.
-
setStatus
void setStatus(int sc)
Sets the status code for this response.
-
getStatus
int getStatus()
Gets the current status code of this response.
-
setContentType
void setContentType(java.lang.String contentType)
Sets the content type of the response being sent to the client, if the response has not been committed yet.
-
getWriter
java.io.PrintWriter getWriter() throws java.io.IOException
Returns aPrintWriter
object that can send character text to the client. Calling flush() on thePrintWriter
commits the response.- Throws:
java.io.IOException
-
setHeader
void setHeader(java.lang.String name, java.lang.String value)
Sets a response header with the given name and value. If the header had already been set, the new value overwrites the previous one.
-
sendRedirect
void sendRedirect(java.lang.String location) throws java.io.IOException
Sends a temporary redirect response to the client using the specified redirect location URL and clears the buffer. The buffer will be replaced with the data set by this method.- Throws:
java.io.IOException
-
addCookie
void addCookie(Cookie cookie)
Adds the specified cookie to the response. This method can be called multiple times to set more than one cookie.
-
getOutputStream
java.io.OutputStream getOutputStream() throws java.io.IOException
Returns aOutputStream
suitable for writing binary data in the response. The servlet container does not encode the binary data. Either this method orgetWriter()
may be called to write the body, not both.- Throws:
java.io.IOException
-
setCharacterEncoding
void setCharacterEncoding(java.lang.String charset)
Sets the character encoding (MIME charset) of the response being sent to the client, for example, to UTF-8.
-
-