Package ej.restserver
Class RestResponse
- java.lang.Object
-
- HTTPResponse
-
- ej.restserver.RestResponse
-
public class RestResponse extends HTTPResponseA simple wrapper over HTTP response, allowing to directly specify MIME type and status code.
-
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_ENCODINGDefault content encoding for Rest response.
-
Constructor Summary
Constructors Constructor Description RestResponse(String status, String mimeType, InputStream data)Creates a new REST response.RestResponse(String status, String mimeType, String text)Creates a new REST response.RestResponse(String status, String mimeType, String text, String encoding)Creates a new REST response.
-
-
-
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 typedata- 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 typetext- 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 typetext- 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
-
-