public class RestApiServlet
extends javax.servlet.http.HttpServlet
Modifier and Type | Class and Description |
---|---|
static class |
RestApiServlet.Globals |
Modifier and Type | Field and Description |
---|---|
static byte[] |
JSON_MAGIC
Garbage prefix inserted before JSON output to prevent XSSI.
|
static String |
X_GERRIT_TRACE |
static String |
XD_AUTHORIZATION |
static String |
XD_CONTENT_TYPE |
static String |
XD_METHOD |
Constructor and Description |
---|
RestApiServlet(RestApiServlet.Globals globals,
com.google.inject.Provider<? extends RestCollection<? extends RestResource,? extends RestResource>> members) |
RestApiServlet(RestApiServlet.Globals globals,
RestCollection<? extends RestResource,? extends RestResource> members) |
Modifier and Type | Method and Description |
---|---|
static long |
replyError(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res,
int statusCode,
String msg,
CacheControl c,
Throwable err) |
static long |
replyError(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res,
int statusCode,
String msg,
Throwable err) |
static long |
replyJson(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res,
boolean allowTracing,
com.google.common.collect.ListMultimap<String,String> config,
Object result)
Sets a JSON reply on the given HTTP servlet response.
|
protected void |
service(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res) |
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service
public static final String X_GERRIT_TRACE
public static final String XD_AUTHORIZATION
public static final String XD_CONTENT_TYPE
public static final String XD_METHOD
public static final byte[] JSON_MAGIC
This prefix is ")]}'\n" and is designed to prevent a web browser from executing the response body if the resource URI were to be referenced using a <script src="...> HTML tag from another web site. Clients using the HTTP interface will need to always strip the first line of response data to remove this magic header.
public RestApiServlet(RestApiServlet.Globals globals, RestCollection<? extends RestResource,? extends RestResource> members)
public RestApiServlet(RestApiServlet.Globals globals, com.google.inject.Provider<? extends RestCollection<? extends RestResource,? extends RestResource>> members)
protected final void service(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) throws javax.servlet.ServletException, IOException
service
in class javax.servlet.http.HttpServlet
javax.servlet.ServletException
IOException
public static long replyJson(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, boolean allowTracing, com.google.common.collect.ListMultimap<String,String> config, Object result) throws IOException
req
- the HTTP servlet requestres
- the HTTP servlet response on which the reply should be setallowTracing
- whether it is allowed to log the reply if tracing is enabled, must not be
set to true
if the reply may contain sensitive dataconfig
- config parameters for the JSON formattingresult
- the object that should be formatted as JSONIOException
public static long replyError(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, int statusCode, String msg, Throwable err) throws IOException
IOException
public static long replyError(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, int statusCode, String msg, CacheControl c, Throwable err) throws IOException
IOException