Package ej.restserver

Class RestResponse


  • public class RestResponse
    extends HTTPResponse
    A simple wrapper over HTTP response, allowing to directly specify MIME type and status code.
    • Field Detail

      • DEFAULT_ENCODING

        public static final String DEFAULT_ENCODING
        Default content encoding for Rest response.
        See Also:
        Constant Field Values
    • Constructor Detail

      • RestResponse

        public RestResponse​(String status,
                            String mimeType,
                            InputStream data)
        Creates a new REST response.
        Parameters:
        status - the response status.
        mimeType - the response MIME type
        data - the data to send.
        See Also:
        HTTPConstants#HTTP_STATUS_BADREQUEST, HTTPConstants#HTTP_STATUS_FORBIDDEN, HTTPConstants#HTTP_STATUS_INTERNALERROR, HTTPConstants#HTTP_STATUS_MEDIA_TYPE, HTTPConstants#HTTP_STATUS_METHOD, HTTPConstants#HTTP_STATUS_NOTACCEPTABLE, HTTPConstants#HTTP_STATUS_NOTFOUND, HTTPConstants#HTTP_STATUS_NOTIMPLEMENTED, HTTPConstants#HTTP_STATUS_NOTMODIFIED, HTTPConstants#HTTP_STATUS_OK, HTTPConstants#HTTP_STATUS_REDIRECT
      • RestResponse

        public RestResponse​(String status,
                            String mimeType,
                            String text)
                     throws UnsupportedEncodingException
        Creates a new REST response.
        Parameters:
        status - the response status.
        mimeType - the response MIME type
        text - the data to send, using default encoding.
        Throws:
        UnsupportedEncodingException - if default encoding is not supported.
        See Also:
        DEFAULT_ENCODING, HTTPConstants#HTTP_STATUS_BADREQUEST, HTTPConstants#HTTP_STATUS_FORBIDDEN, HTTPConstants#HTTP_STATUS_INTERNALERROR, HTTPConstants#HTTP_STATUS_MEDIA_TYPE, HTTPConstants#HTTP_STATUS_METHOD, HTTPConstants#HTTP_STATUS_NOTACCEPTABLE, HTTPConstants#HTTP_STATUS_NOTFOUND, HTTPConstants#HTTP_STATUS_NOTIMPLEMENTED, HTTPConstants#HTTP_STATUS_NOTMODIFIED, HTTPConstants#HTTP_STATUS_OK, HTTPConstants#HTTP_STATUS_REDIRECT
      • RestResponse

        public RestResponse​(String status,
                            String mimeType,
                            String text,
                            String encoding)
                     throws UnsupportedEncodingException
        Creates a new REST response.
        Parameters:
        status - the response status.
        mimeType - the response MIME type
        text - the data to send.
        encoding - the data encoding.
        Throws:
        UnsupportedEncodingException - if given data encoding is not supported.
        See Also:
        HTTPConstants#HTTP_STATUS_BADREQUEST, HTTPConstants#HTTP_STATUS_FORBIDDEN, HTTPConstants#HTTP_STATUS_INTERNALERROR, HTTPConstants#HTTP_STATUS_MEDIA_TYPE, HTTPConstants#HTTP_STATUS_METHOD, HTTPConstants#HTTP_STATUS_NOTACCEPTABLE, HTTPConstants#HTTP_STATUS_NOTFOUND, HTTPConstants#HTTP_STATUS_NOTIMPLEMENTED, HTTPConstants#HTTP_STATUS_NOTMODIFIED, HTTPConstants#HTTP_STATUS_OK, HTTPConstants#HTTP_STATUS_REDIRECT