Package com.google.gerrit.httpd.restapi
Class RestApiServlet
java.lang.Object
javax.servlet.GenericServlet
javax.servlet.http.HttpServlet
com.google.gerrit.httpd.restapi.RestApiServlet
- All Implemented Interfaces:
Serializable
,javax.servlet.Servlet
,javax.servlet.ServletConfig
- Direct Known Subclasses:
AccessRestApiServlet
,AccountsRestApiServlet
,ChangesRestApiServlet
,ConfigRestApiServlet
,GroupsRestApiServlet
,ProjectsRestApiServlet
public class RestApiServlet
extends javax.servlet.http.HttpServlet
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final byte[]
Garbage prefix inserted before JSON output to prevent XSSI.static final int
static final int
static final int
static final String
static final String
static final String
static final String
static final String
static final String
static final String
-
Constructor Summary
ConstructorsConstructorDescriptionRestApiServlet
(RestApiServlet.Globals globals, RestCollection<? extends RestResource, ? extends RestResource> members) RestApiServlet
(RestApiServlet.Globals globals, com.google.inject.Provider<? extends RestCollection<? extends RestResource, ? extends RestResource>> members) -
Method Summary
Modifier and TypeMethodDescriptionstatic long
replyError
(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, int statusCode, String msg, CacheControl cacheControl, 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 final void
service
(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, init, log, log
-
Field Details
-
X_GERRIT_DEADLINE
- See Also:
-
X_GERRIT_TRACE
- See Also:
-
X_GERRIT_UPDATED_REF
- See Also:
-
X_GERRIT_UPDATED_REF_ENABLED
- See Also:
-
XD_AUTHORIZATION
- See Also:
-
XD_CONTENT_TYPE
- See Also:
-
XD_METHOD
- See Also:
-
SC_UNPROCESSABLE_ENTITY
public static final int SC_UNPROCESSABLE_ENTITY- See Also:
-
SC_TOO_MANY_REQUESTS
public static final int SC_TOO_MANY_REQUESTS- See Also:
-
SC_CLIENT_CLOSED_REQUEST
public static final int SC_CLIENT_CLOSED_REQUEST- See Also:
-
JSON_MAGIC
public static final byte[] JSON_MAGICGarbage prefix inserted before JSON output to prevent XSSI.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.
-
-
Constructor Details
-
RestApiServlet
public RestApiServlet(RestApiServlet.Globals globals, RestCollection<? extends RestResource, ? extends RestResource> members) -
RestApiServlet
public RestApiServlet(RestApiServlet.Globals globals, com.google.inject.Provider<? extends RestCollection<? extends RestResource, ? extends RestResource>> members)
-
-
Method Details
-
service
protected final void service(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) throws javax.servlet.ServletException, IOException - Overrides:
service
in classjavax.servlet.http.HttpServlet
- Throws:
javax.servlet.ServletException
IOException
-
replyJson
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 IOExceptionSets a JSON reply on the given HTTP servlet response.- Parameters:
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 totrue
if the reply may contain sensitive dataconfig
- config parameters for the JSON formattingresult
- the object that should be formatted as JSON- Returns:
- the length of the response
- Throws:
IOException
-
replyError
public static long replyError(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, int statusCode, String msg, Throwable err) throws IOException - Throws:
IOException
-
replyError
public static long replyError(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, int statusCode, String msg, CacheControl cacheControl, Throwable err) throws IOException - Throws:
IOException
-