001package com.esri.arcgis.enterprise.interceptor;
002
003import jakarta.servlet.ServletOutputStream;
004
005import java.io.IOException;
006import java.io.PrintWriter;
007import java.util.Collection;
008
009public interface IInterceptorResponse {
010
011    /**
012     * Sends an error response to the client using the specified status code and clears the buffer.
013     *
014     * @param sc - the error status code
015     * @param msg - the descriptive message
016     * @throws IOException      If an input or output exception occurs
017     */
018    void sendError(int sc, String msg) throws IOException;
019
020    /**
021     * Sends an error response to the client using the specified status code and clears the buffer.
022     *
023     * @param sc - the error status code
024     * @throws IOException      If an input or output exception occurs
025     */
026    void sendError(int sc) throws IOException;
027
028    /**
029     * Sets a response header with the given name and value. If the header had already been set, the new value overwrites the previous one.
030     *
031     * @param name - the name of the header
032     * @param value - the header value
033     */
034    void setHeader(String name, String value);
035
036    /**
037     * Adds a response header with the given name and value.
038     *
039     * @param name - the name of the header
040     * @param value - the additional header value
041     */
042    void addHeader(String name, String value);
043
044    /**
045     * Sets the status code for this response.
046     *
047     * @param sc - the status code
048     */
049    void setStatus(int sc);
050
051    /**
052     * Returns the value of the specified request header as a String
053     *
054     * @param name - the name of the response header whose value to return
055     * @return the value of the response header with the given name, or null if no header with the given name has been set on this response
056     */
057    String getHeader(String name);
058
059    /**
060     * Gets the values of the response header with the given name.
061     *
062     * @param name - the name of the response header whose values to return
063     * @return a Collection of the values of the response header with the given name
064     */
065    Collection<String> getHeaders(String name);
066
067    /**
068     * Gets the names of the headers of this response.
069     *
070     * @return a Collection of the names of the headers of this response
071     */
072    Collection<String> getHeaderNames();
073
074    /**
075     * Returns a ServletOutputStream suitable for writing binary data in the response.
076     *
077     * @return a ServletOutputStream for writing binary data
078     * @throws IOException      if the getWriter method has been called on this response
079     */
080    ServletOutputStream getOutputStream() throws IOException;
081
082    /**
083     * Returns a PrintWriter object that can send character text to the client.
084     *
085     * @return a PrintWriter object that can return character data to the client
086     * @throws IOException      if an input or output exception occurred
087     */
088    PrintWriter getWriter() throws IOException;
089
090    /**
091     * Forces any content in the buffer to be written to the client. A call to this method automatically commits the response, meaning the status code and headers will be written.
092     * @throws IOException
093     */
094    void flushBuffer() throws IOException;
095
096    /**
097     * Clears any data that exists in the buffer as well as the status code and headers.
098     *
099     */
100    void reset();
101
102    /**
103     * Sets the character encoding of the response being sent to the client.
104     *
105     * @param var1 - a String specifying only the character
106     */
107    void setCharacterEncoding(String var1);
108
109    /**
110     * Returns the name of the character encoding
111     *
112     */
113    String getCharacterEncoding();
114
115    /**
116     * Returns a boolean indicating if the response has been committed. A committed response has already had its status code and headers written.
117     *
118     * @return a boolean indicating if the response has been committed
119     */
120    boolean isCommitted();
121
122    /**
123     * Returns a String that indicates the content-type of the response
124     * @return String that indicates the content-type of the response
125     */
126    String getContentType();
127}