本文整理了Java中org.eclipse.jetty.server.Handler.handle()
方法的一些代码示例,展示了Handler.handle()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Handler.handle()
方法的具体详情如下:
包路径:org.eclipse.jetty.server.Handler
类名称:Handler
方法名:handle
[英]Handle a request.
[中]处理请求。
代码示例来源:origin: dropwizard/dropwizard
@Override
public void handle(String target,
Request baseRequest,
HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
final Handler handler = handlers.getBest(baseRequest.getRequestURI());
if (handler != null) {
handler.handle(target, baseRequest, request, response);
}
}
代码示例来源:origin: dropwizard/dropwizard
@Override
public void handle(String target,
Request baseRequest,
HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
final Connector connector = baseRequest.getHttpChannel().getConnector();
for (Entry entry : entries) {
// reference equality works fine — none of the connectors implement #equals(Object)
if (entry.connector == connector) {
entry.handler.handle(target, baseRequest, request, response);
return;
}
}
}
}
代码示例来源:origin: AsyncHttpClient/async-http-client
@Override
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
Handler handler = HttpServer.this.handlers.poll();
if (handler == null) {
response.sendError(500, "No handler enqueued");
response.getOutputStream().flush();
response.getOutputStream().close();
} else {
handler.handle(target, baseRequest, request, response);
}
}
}
代码示例来源:origin: Codecademy/EventHub
@Override
public void handle(String s, Request request, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws IOException, ServletException {
Map<String, String[]> params = httpServletRequest.getParameterMap();
if(params.containsKey("callback")) {
OutputStream out = httpServletResponse.getOutputStream();
GenericResponseWrapper wrapper = new GenericResponseWrapper(httpServletResponse);
try {
handler.handle(s, request, httpServletRequest, wrapper);
if (httpServletResponse.getStatus() >= 400) {
out.write((params.get("callback")[0] + "({error: 'error'});").getBytes());
} else {
out.write((params.get("callback")[0] + "(").getBytes());
out.write(wrapper.getData());
out.write(");".getBytes());
}
wrapper.setContentType("text/javascript;charset=UTF-8");
out.close();
} catch (Exception e) {
out.write((params.get("callback")[0] + "({error: 'error'});").getBytes());
wrapper.setContentType("text/javascript;charset=UTF-8");
out.close();
throw e;
}
} else {
handler.handle(s, request, httpServletRequest, httpServletResponse);
}
}
代码示例来源:origin: gocd/gocd
@Test
public void shouldNotHandleForRails4DevelopmentMode() throws IOException, ServletException {
when(systemEnvironment.useCompressedJs()).thenReturn(false);
String target = "/go/assets/junk";
Request request = mock(Request.class);
HttpServletResponse response = mock(HttpServletResponse.class);
Request baseRequest = mock(Request.class);
ResourceHandler resourceHandler = mock(ResourceHandler.class);
ReflectionUtil.setField(((HandlerWrapper) handler.getHandler()).getHandler(), "resourceHandler", resourceHandler);
handler.getHandler().handle(target, baseRequest, request, response);
verify(resourceHandler, never()).handle(any(String.class), any(Request.class), any(HttpServletRequest.class), any(HttpServletResponse.class));
}
代码示例来源:origin: gocd/gocd
@Test
public void shouldPassOverHandlingToResourceHandler() throws Exception {
when(systemEnvironment.useCompressedJs()).thenReturn(true);
String target = "/go/assets/junk";
Request request = mock(Request.class);
HttpServletResponse response = mock(HttpServletResponse.class);
Request baseRequest = mock(Request.class);
AssetsContextHandler.AssetsHandler resourceHandler = mock(AssetsContextHandler.AssetsHandler.class);
handler.setHandler(resourceHandler);
handler.getHandler().handle(target, baseRequest, request, response);
verify(resourceHandler).handle(target, baseRequest, request, response);
}
代码示例来源:origin: gocd/gocd
private MockResponse request(String target, String acceptHeaderValue) throws Exception {
Request baseRequest = mock(Request.class);
HttpFields httpFields = new HttpFields();
if (acceptHeaderValue != null) {
httpFields.add("Accept", acceptHeaderValue);
}
when(baseRequest.getHttpFields()).thenReturn(httpFields);
HttpServletRequest servletRequest = mock(HttpServletRequest.class);
HttpServletResponse servletResponse = mock(HttpServletResponse.class);
PrintWriter printWriter = mock(PrintWriter.class);
when(servletResponse.getWriter()).thenReturn(printWriter);
handler.getHandler().handle(target, baseRequest, servletRequest, servletResponse);
return new MockResponse(servletResponse, printWriter);
}
代码示例来源:origin: neo4j/neo4j
@Override
public void handle( String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response ) throws IOException, ServletException
{
HttpChannel httpChannel = baseRequest.getHttpChannel();
if ( httpChannel != null ) // if the channel is not null, all good, you handle yourself.
{
super.handle( target, baseRequest, request, response );
}
else // if we do not have a real channel, then we just log ourselves
{
try
{
if ( _handler != null )
{
_handler.handle( target, baseRequest, request, response );
}
}
finally
{
RequestLog requestLog = getRequestLog();
if ( requestLog != null && baseRequest.getDispatcherType() == DispatcherType.REQUEST )
{
requestLog.log( baseRequest, (Response) response );
}
}
}
}
}
代码示例来源:origin: org.eclipse.jetty/jetty-security
handler.handle(pathInContext, baseRequest, request, response);
if (authenticator!=null)
authenticator.secureResponse(request, response, isAuthMandatory, userAuth);
handler.handle(pathInContext, baseRequest, request, response);
if (_identityService!=null)
previousIdentity = _identityService.associate(null);
handler.handle(pathInContext, baseRequest, request, response);
if (authenticator!=null)
authenticator.secureResponse(request, response, isAuthMandatory, null);
handler.handle(pathInContext, baseRequest, request, response);
代码示例来源:origin: com.ovea.tajin.server/tajin-server-jetty9
public final void nextHandle(String target, final Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
// this method has been manually inlined in several locations, but
// is called protected by an if(never()), so your IDE can find those
// locations if this code is changed.
if (_nextScope!=null && _nextScope==_handler)
_nextScope.doHandle(target,baseRequest,request, response);
else if (_handler!=null)
_handler.handle(target,baseRequest, request, response);
}
代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.jetty.server
public final void nextHandle(String target, final Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
// this method has been manually inlined in several locations, but
// is called protected by an if(never()), so your IDE can find those
// locations if this code is changed.
if (_nextScope!=null && _nextScope==_handler)
_nextScope.doHandle(target,baseRequest,request, response);
else if (_handler!=null)
_handler.handle(target,baseRequest, request, response);
}
代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-plus
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
if (_handler!=null && isStarted())
{
_handler.handle(target,baseRequest, request, response);
}
}
代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-all-server
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
if (_handler != null && isStarted())
{
_handler.handle(target,baseRequest,request,response);
}
}
代码示例来源:origin: io.dropwizard/dropwizard-jetty
@Override
public void handle(String target,
Request baseRequest,
HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
final Handler handler = handlers.getBest(baseRequest.getRequestURI());
if (handler != null) {
handler.handle(target, baseRequest, request, response);
}
}
}
代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-all-server
@Override
public void doHandle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
// start manual inline of nextHandle(target,baseRequest,request,response);
if (never())
nextHandle(target,baseRequest,request,response);
else if (_nextScope != null && _nextScope == _handler)
_nextScope.doHandle(target,baseRequest,request,response);
else if (_handler != null)
_handler.handle(target,baseRequest,request,response);
// end manual inline
}
代码示例来源:origin: com.ovea.tajin.server/tajin-server-jetty9
@Override
public void doHandle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
// start manual inline of nextHandle(target,baseRequest,request,response);
if (never())
nextHandle(target,baseRequest,request,response);
else if (_nextScope != null && _nextScope == _handler)
_nextScope.doHandle(target,baseRequest,request,response);
else if (_handler != null)
_handler.handle(target,baseRequest,request,response);
// end manual inline
}
代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.jetty.server
@Override
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
{
if (baseRequest.getDispatcherType()==DispatcherType.REQUEST)
baseRequest.getHttpChannel().addRequestLog(_requestLog);
if (_handler!=null)
_handler.handle(target,baseRequest, request, response);
}
代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-plus
@Override
public void doHandle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
// start manual inline of nextHandle(target,baseRequest,request,response);
if (never())
nextHandle(target,baseRequest,request,response);
else if (_nextScope != null && _nextScope == _handler)
_nextScope.doHandle(target,baseRequest,request,response);
else if (_handler != null)
_handler.handle(target,baseRequest,request,response);
// end manual inline
}
代码示例来源:origin: com.ovea.tajin.servers/tajin-server-jetty9
@Override
public void doHandle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
// start manual inline of nextHandle(target,baseRequest,request,response);
if (never())
nextHandle(target,baseRequest,request,response);
else if (_nextScope != null && _nextScope == _handler)
_nextScope.doHandle(target,baseRequest,request,response);
else if (_handler != null)
_handler.handle(target,baseRequest,request,response);
// end manual inline
}
代码示例来源:origin: org.fabric3/fabric3-jetty
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
if (!request.isSecure()) {
baseRequest.getResponse().sendRedirect("https://" + baseRequest.getServerName() + ":" + httpsPort + baseRequest.getPathInfo());
baseRequest.setHandled(true);
} else {
getHandler().handle(target, baseRequest, request, response);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!