MCPcopy Create free account
hub / github.com/adblockplus/adblockplusandroid / Handler

Interface Handler

src/sunlabs/brazil/server/Handler.java:103–155  ·  view source on GitHub ↗

The interface for writing HTTP handlers. Provides basic functionality to accept HTTP requests and dispatch to methods that handle the request. The #init(Server, String) method is called before this Handler processes the first HTTP request, to allow it to prepare itself, suc

Source from the content-addressed store, hash-verified

101 */
102
103public interface Handler {
104 /**
105 * Initializes the handler.
106 *
107 * @param server
108 * The HTTP server that created this <code>Handler</code>.
109 * Typical <code>Handler</code>s will use {@link Server#props}
110 * to obtain run-time configuration information.
111 *
112 * @param prefix
113 * The handlers <i>name</i>.
114 * The string this <code>Handler</code> may prepend to all
115 * of the keys that it uses to extract configuration information
116 * from {@link Server#props}. This is set (by the {@link Server}
117 * and {@link ChainHandler}) to help avoid configuration parameter
118 * namespace collisions.
119 *
120 * @return <code>true</code> if this <code>Handler</code> initialized
121 * successfully, <code>false</code> otherwise. If
122 * <code>false</code> is returned, this <code>Handler</code>
123 * should not be used.
124 */
125 boolean init(Server server, String prefix);
126
127 /**
128 * Responds to an HTTP request.
129 *
130 * @param request
131 * The <code>Request</code> object that represents the HTTP
132 * request.
133 *
134 * @return <code>true</code> if the request was handled. A request was
135 * handled if a response was supplied to the client, typically
136 * by calling <code>Request.sendResponse()</code> or
137 * <code>Request.sendError</code>.
138 *
139 * @throws IOException
140 * if there was an I/O error while sending the response to
141 * the client. Typically, in that case, the <code>Server</code>
142 * will (try to) send an error message to the client and then
143 * close the client's connection.
144 * <p>
145 * The <code>IOException</code> should not be used to silently
146 * ignore problems such as being unable to access some
147 * server-side resource (for example getting a
148 * <code>FileNotFoundException</code> due to not being able
149 * to open a file). In that case, the <code>Handler</code>'s
150 * duty is to turn that <code>IOException</code> into a
151 * HTTP response indicating, in this case, that a file could
152 * not be found.
153 */
154 boolean respond(Request request) throws IOException;
155}

Callers 4

initHandlerMethod · 0.95
initMethod · 0.65
runMethod · 0.65
respondMethod · 0.65

Implementers 4

ChainHandlersrc/sunlabs/brazil/server/ChainHandler
TransparentProxyHandlersrc/org/adblockplus/brazil/Transparent
BaseRequestHandlersrc/org/adblockplus/brazil/BaseRequest
RequestHandlersrc/org/adblockplus/brazil/RequestHand

Calls

no outgoing calls

Tested by

no test coverage detected