當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。