当前位置: 首页>>代码示例>>Java>>正文


Java HttpRequestHandler类代码示例

本文整理汇总了Java中org.jetbrains.ide.HttpRequestHandler的典型用法代码示例。如果您正苦于以下问题:Java HttpRequestHandler类的具体用法?Java HttpRequestHandler怎么用?Java HttpRequestHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


HttpRequestHandler类属于org.jetbrains.ide包,在下文中一共展示了HttpRequestHandler类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: process

import org.jetbrains.ide.HttpRequestHandler; //导入依赖的package包/类
@Override
protected boolean process(ChannelHandlerContext context, HttpRequest request, QueryStringDecoder urlDecoder) throws IOException, ImageWriteException {
  HttpRequestHandler connectedHandler = (HttpRequestHandler)context.getAttachment();
  if (connectedHandler != null) {
    if (connectedHandler.isSupported(request) && connectedHandler.process(urlDecoder, request, context)) {
      return true;
    }
    // prev cached connectedHandler is not suitable for this request, so, let's find it again
    context.setAttachment(null);
  }

  if (urlDecoder.getPath().equals("/favicon.ico")) {
    Icon icon = IconLoader.findIcon(ApplicationInfoEx.getInstanceEx().getSmallIconUrl());
    if (icon != null) {
      BufferedImage image = UIUtil.createImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
      icon.paintIcon(null, image.getGraphics(), 0, 0);
      byte[] icoBytes = Sanselan.writeImageToBytes(image, ImageFormat.IMAGE_FORMAT_ICO, null);
      Responses.send(icoBytes, FileResponses.createResponse(urlDecoder.getPath()), request, context);
      return true;
    }
  }

  for (HttpRequestHandler handler : BuiltInServerManager.EP_NAME.getExtensions()) {
    try {
      if (handler.isSupported(request) && handler.process(urlDecoder, request, context)) {
        if (context.getAttachment() == null) {
          context.setAttachment(handler);
        }
        return true;
      }
    }
    catch (Throwable e) {
      BuiltInServer.LOG.error(e);
    }
  }
  return false;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:38,代码来源:DelegatingHttpRequestHandler.java

示例2: process

import org.jetbrains.ide.HttpRequestHandler; //导入依赖的package包/类
@Override
protected boolean process(@NotNull ChannelHandlerContext context,
                          @NotNull FullHttpRequest request,
                          @NotNull QueryStringDecoder urlDecoder) throws IOException, ImageWriteException {
  Attribute<HttpRequestHandler> prevHandlerAttribute = context.attr(PREV_HANDLER);
  HttpRequestHandler connectedHandler = prevHandlerAttribute.get();
  if (connectedHandler != null) {
    if (connectedHandler.isSupported(request) && connectedHandler.process(urlDecoder, request, context)) {
      return true;
    }
    // prev cached connectedHandler is not suitable for this request, so, let's find it again
    prevHandlerAttribute.set(null);
  }

  for (HttpRequestHandler handler : HttpRequestHandler.EP_NAME.getExtensions()) {
    try {
      if (handler.isSupported(request) && handler.process(urlDecoder, request, context)) {
        prevHandlerAttribute.set(handler);
        return true;
      }
    }
    catch (Throwable e) {
      Logger.getInstance(BuiltInServer.class).error(e);
    }
  }

  if (urlDecoder.path().equals("/favicon.ico")) {
    Icon icon = IconLoader.findIcon(ApplicationInfoEx.getInstanceEx().getSmallIconUrl());
    if (icon != null) {
      BufferedImage image = UIUtil.createImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
      icon.paintIcon(null, image.getGraphics(), 0, 0);
      byte[] icoBytes = Sanselan.writeImageToBytes(image, ImageFormat.IMAGE_FORMAT_ICO, null);
      HttpResponse response = Responses.response(FileResponses.getContentType(urlDecoder.path()), Unpooled.wrappedBuffer(icoBytes));
      Responses.addNoCache(response);
      Responses.send(response, context.channel(), request);
      return true;
    }
  }

  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:42,代码来源:DelegatingHttpRequestHandler.java

示例3: process

import org.jetbrains.ide.HttpRequestHandler; //导入依赖的package包/类
@Override
protected boolean process(ChannelHandlerContext context, FullHttpRequest request, QueryStringDecoder urlDecoder) throws Exception {
  ThrowableNotNullFunction<HttpRequestHandler, Boolean, IOException> checkAndProcess = httpRequestHandler -> {
    return httpRequestHandler.isSupported(request) &&
           !NettyKt.isWriteFromBrowserWithoutOrigin(request) &&
           httpRequestHandler.isAccessible(request) &&
           httpRequestHandler.process(urlDecoder, request, context);
  };


  Attribute<HttpRequestHandler> prevHandlerAttribute = context.channel().attr(PREV_HANDLER);
  HttpRequestHandler connectedHandler = prevHandlerAttribute.get();
  if (connectedHandler != null) {
    if (checkAndProcess.fun(connectedHandler)) {
      return true;
    }
    // prev cached connectedHandler is not suitable for this request, so, let's find it again
    prevHandlerAttribute.set(null);
  }

  for (HttpRequestHandler handler : HttpRequestHandler.EP_NAME.getExtensions()) {
    try {
      if (checkAndProcess.fun(handler)) {
        prevHandlerAttribute.set(handler);
        return true;
      }
    }
    catch (Throwable e) {
      Logger.getInstance(BuiltInServer.class).error(e);
    }
  }

  if (urlDecoder.path().equals("/favicon.ico")) {
    Icon icon = Application.get().getIcon();
    BufferedImage image = UIUtil.createImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
    icon.paintIcon(null, image.getGraphics(), 0, 0);
    byte[] icoBytes = Imaging.writeImageToBytes(image, ImageFormats.ICO, null);

    HttpResponse response = Responses.response(FileResponses.getContentType(urlDecoder.path()), Unpooled.wrappedBuffer(icoBytes));
    response = Responses.addNoCache(response);
    Responses.send(response, context.channel(), request);
    return true;
  }

  return false;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:47,代码来源:DelegatingHttpRequestHandler.java


注:本文中的org.jetbrains.ide.HttpRequestHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。