All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.dreampie.common.Response Maven / Gradle / Ivy

package cn.dreampie.common;

import cn.dreampie.common.http.result.HttpStatus;

import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.nio.charset.Charset;

/**
 * Date: 2/6/13
 * Time: 9:46 PM
 */
public interface Response {
  HttpStatus getStatus();

  Response setStatus(HttpStatus status);

  /**
   * Sets the content type of this response.
   * 

* It is highly recommended to call this before writing the response content, especially if you want to use getWriter(). *

* The response charset may be set when calling this, either to the provided charset in the content type, * or by default to UTF-8 if it is a 'text' content type. * * @param s the content type * @return the current response */ Response setContentType(String s); /** * Returns the charset set on this response if any. *

* The charset is set when calling setContentType, either to the provided charset in the content type, * or by default to UTF-8 if it is a 'text' content type. * * @return the charset */ Charset getCharset(); /** * A writer you can write to to send response as text. *

* The charset used is the one returned by getCharset(), or UTF-8 if not set. *

* It is strongly recommended to call setContentType to set the charset before calling this method. * * @return a PrintWriter which can be used to write the response. * @throws java.io.IOException */ PrintWriter getWriter() throws IOException; OutputStream getOutputStream() throws IOException; Response addCookie(String cookie, String value); Response addCookie(String cookie, String value, int expires); Response clearCookie(String cookie); Response setHeader(String headerName, String header); /** * Returns the value of a header previously set with setHeader(). * * @param headerName the name of the header to get. * @return the header value. */ String getHeader(String headerName); /** * Unwraps the underlying native implementation of given class. *

* Examnple: This is a HttpServletRequest in a servlet container. * * @param clazz the class of the underlying implementation * @param unwrapped class * @return the unwrapped implementation. * @throws IllegalArgumentException if the underlying implementation is not of given type. */ T unwrap(Class clazz); boolean isClosed(); }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy