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


Java RPCServletUtils类代码示例

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


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

示例1: doGet

import com.google.gwtjsonrpc.server.RPCServletUtils; //导入依赖的package包/类
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse rsp) throws IOException {
  final byte[] tosend;
  if (RPCServletUtils.acceptsGzipEncoding(req)) {
    rsp.setHeader("Content-Encoding", "gzip");
    tosend = compressed;
  } else {
    tosend = raw;
  }

  CacheHeaders.setNotCacheable(rsp);
  rsp.setContentType("text/html");
  rsp.setCharacterEncoding(HtmlDomUtil.ENC.name());
  rsp.setContentLength(tosend.length);
  try (OutputStream out = rsp.getOutputStream()) {
    out.write(tosend);
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:19,代码来源:LegacyGerritServlet.java

示例2: doGet

import com.google.gwtjsonrpc.server.RPCServletUtils; //导入依赖的package包/类
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse rsp) throws IOException {
  if (raw_css != null) {
    rsp.setContentType("text/css");
    rsp.setCharacterEncoding(UTF_8.name());
    final byte[] toSend;
    if (RPCServletUtils.acceptsGzipEncoding(req)) {
      rsp.setHeader("Content-Encoding", "gzip");
      toSend = gz_css;
    } else {
      toSend = raw_css;
    }
    rsp.setContentLength(toSend.length);
    rsp.setDateHeader("Last-Modified", modified);
    CacheHeaders.setCacheable(req, rsp, 5, TimeUnit.MINUTES);

    try (ServletOutputStream os = rsp.getOutputStream()) {
      os.write(toSend);
    }
  } else {
    CacheHeaders.setNotCacheable(rsp);
    rsp.sendError(HttpServletResponse.SC_NOT_FOUND);
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:25,代码来源:GitwebCssServlet.java

示例3: doFilter

import com.google.gwtjsonrpc.server.RPCServletUtils; //导入依赖的package包/类
@Override
public void doFilter(final ServletRequest request, ServletResponse response, FilterChain chain)
    throws IOException, ServletException {
  if (isSessionValid((HttpServletRequest) request)) {
    chain.doFilter(request, response);
  } else {
    // Not signed in yet. Since the browser state might have an anchor
    // token which we want to capture and carry through the auth process
    // we send back JavaScript now to capture that, and do the real work
    // of redirecting to the authentication area.
    //
    final HttpServletRequest req = (HttpServletRequest) request;
    final HttpServletResponse rsp = (HttpServletResponse) response;
    final byte[] tosend;
    if (RPCServletUtils.acceptsGzipEncoding(req)) {
      rsp.setHeader("Content-Encoding", "gzip");
      tosend = signInGzip;
    } else {
      tosend = signInRaw;
    }

    CacheHeaders.setNotCacheable(rsp);
    rsp.setContentType("text/html");
    rsp.setCharacterEncoding(HtmlDomUtil.ENC.name());
    rsp.setContentLength(tosend.length);
    try (OutputStream out = rsp.getOutputStream()) {
      out.write(tosend);
    }
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:31,代码来源:HttpAuthFilter.java

示例4: doGet

import com.google.gwtjsonrpc.server.RPCServletUtils; //导入依赖的package包/类
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse rsp) throws IOException {
  Page.Content page = select(req);
  StringWriter w = new StringWriter();
  CurrentUser user = currentUser.get();
  if (user.isIdentifiedUser()) {
    w.write(HPD_ID + ".accountDiffPref=");
    json(getDiffPreferences(user.asIdentifiedUser()), w);
    w.write(";");

    w.write(HPD_ID + ".theme=");
    json(signedInTheme, w);
    w.write(";");
  } else {
    w.write(HPD_ID + ".theme=");
    json(signedOutTheme, w);
    w.write(";");
  }
  plugins(w);
  messages(w);

  byte[] hpd = w.toString().getBytes(UTF_8);
  byte[] raw = Bytes.concat(page.part1, hpd, page.part2);
  byte[] tosend;
  if (RPCServletUtils.acceptsGzipEncoding(req)) {
    rsp.setHeader("Content-Encoding", "gzip");
    tosend = HtmlDomUtil.compress(raw);
  } else {
    tosend = raw;
  }

  CacheHeaders.setNotCacheable(rsp);
  rsp.setContentType("text/html");
  rsp.setCharacterEncoding(HtmlDomUtil.ENC.name());
  rsp.setContentLength(tosend.length);
  try (OutputStream out = rsp.getOutputStream()) {
    out.write(tosend);
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:40,代码来源:HostPageServlet.java

示例5: maybeStream

import com.google.gwtjsonrpc.server.RPCServletUtils; //导入依赖的package包/类
/**
 * Maybe stream a path to the response, depending on the properties of the file and cache headers
 * in the request.
 *
 * @param p path to stream
 * @param req HTTP request.
 * @param rsp HTTP response.
 * @return true if the response was written (either the file contents or an error); false if the
 *     path is too small to stream and should be cached.
 */
private boolean maybeStream(Path p, HttpServletRequest req, HttpServletResponse rsp)
    throws IOException {
  try {
    if (Files.size(p) < cacheFileSizeLimitBytes) {
      return false;
    }
  } catch (NoSuchFileException e) {
    cache.put(p, Resource.NOT_FOUND);
    notFound(rsp);
    return true;
  }

  long lastModified = getLastModifiedTime(p).toMillis();
  if (req.getDateHeader(IF_MODIFIED_SINCE) >= lastModified) {
    rsp.setStatus(SC_NOT_MODIFIED);
    return true;
  }

  if (lastModified > 0) {
    rsp.setDateHeader(LAST_MODIFIED, lastModified);
  }
  if (!CacheHeaders.hasCacheHeader(rsp)) {
    CacheHeaders.setCacheable(req, rsp, 15, MINUTES, refresh);
  }
  rsp.setContentType(contentType(p.toString()));

  OutputStream out = rsp.getOutputStream();
  GZIPOutputStream gz = null;
  if (RPCServletUtils.acceptsGzipEncoding(req)) {
    rsp.setHeader(CONTENT_ENCODING, "gzip");
    gz = new GZIPOutputStream(out);
    out = gz;
  }
  Files.copy(p, out);
  if (gz != null) {
    gz.finish();
  }
  return true;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:50,代码来源:ResourceServlet.java

示例6: doGet

import com.google.gwtjsonrpc.server.RPCServletUtils; //导入依赖的package包/类
@Override
protected void doGet(final HttpServletRequest req, final HttpServletResponse rsp)
    throws IOException {
  final Resource p = local(req);
  if (p == null) {
    CacheHeaders.setNotCacheable(rsp);
    rsp.setStatus(HttpServletResponse.SC_NOT_FOUND);
    return;
  }

  final String type = contentType(p.getName());
  final byte[] tosend;
  if (!type.equals("application/x-javascript") && RPCServletUtils.acceptsGzipEncoding(req)) {
    rsp.setHeader("Content-Encoding", "gzip");
    tosend = compress(readResource(p));
  } else {
    tosend = readResource(p);
  }

  CacheHeaders.setCacheable(req, rsp, 12, TimeUnit.HOURS);
  rsp.setDateHeader("Last-Modified", p.getLastModified());
  rsp.setContentType(type);
  rsp.setContentLength(tosend.length);
  try (OutputStream out = rsp.getOutputStream()) {
    out.write(tosend);
  }
}
 
开发者ID:GerritCodeReview,项目名称:plugins_github,代码行数:28,代码来源:VelocityStaticServlet.java

示例7: doGetDirectory

import com.google.gwtjsonrpc.server.RPCServletUtils; //导入依赖的package包/类
private void doGetDirectory(Entry ent, HttpServletRequest req, HttpServletResponse rsp)
    throws IOException {
  String path = "/tools/" + ent.getPath();
  Document page = newDocument();

  Element html = page.createElement("html");
  Element head = page.createElement("head");
  Element title = page.createElement("title");
  Element body = page.createElement("body");

  page.appendChild(html);
  html.appendChild(head);
  html.appendChild(body);
  head.appendChild(title);

  title.setTextContent("Gerrit Code Review - " + path);

  Element h1 = page.createElement("h1");
  h1.setTextContent(title.getTextContent());
  body.appendChild(h1);

  Element ul = page.createElement("ul");
  body.appendChild(ul);

  for (Entry e : ent.getChildren()) {
    String name = e.getName();
    if (e.getType() == Entry.Type.DIR && !name.endsWith("/")) {
      name += "/";
    }

    Element li = page.createElement("li");
    Element a = page.createElement("a");
    a.setAttribute("href", name);
    a.setTextContent(name);
    li.appendChild(a);
    ul.appendChild(li);
  }

  body.appendChild(page.createElement("hr"));

  Element footer = page.createElement("p");
  footer.setAttribute("style", "text-align: right; font-style: italic");
  footer.setTextContent("Powered by Gerrit Code Review " + Version.getVersion());
  body.appendChild(footer);

  byte[] tosend = toUTF8(page);
  if (RPCServletUtils.acceptsGzipEncoding(req)) {
    rsp.setHeader("Content-Encoding", "gzip");
    tosend = compress(tosend);
  }

  rsp.setDateHeader(HDR_EXPIRES, 0L);
  rsp.setHeader(HDR_PRAGMA, "no-cache");
  rsp.setHeader(HDR_CACHE_CONTROL, "no-cache, must-revalidate");
  rsp.setContentType("text/html");
  rsp.setCharacterEncoding(UTF_8.name());
  rsp.setContentLength(tosend.length);
  try (OutputStream out = rsp.getOutputStream()) {
    out.write(tosend);
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:62,代码来源:ToolServlet.java


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