Package com.google.caja.lexer

Examples of com.google.caja.lexer.FetchedData


    if (req.getRequestURI().contains(";")) {
      throw new ServletException("Invalid URL path parameter");
    }

    MessageQueue mq = new SimpleMessageQueue();
    FetchedData result = service.handle(inputFetchedData, args, mq);
    if (result == null) {
      closeBadRequest(resp, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, mq);
      return;
    }

    resp.setStatus(HttpServletResponse.SC_OK);

    String responseContentType = result.getContentType();
    if (result.getCharSet() != null) {
      responseContentType += ";charset=" + result.getCharSet();
    }
    if (containsNewline(responseContentType)) {
      throw new IllegalArgumentException(responseContentType);
    }

    try {
      byte[] content = result.getByteContent();
      resp.setContentType(responseContentType);
      resp.setContentLength(content.length);
      resp.setHeader(UMP.a, UMP.b);
      resp.setHeader("X-Content-Type-Options", "nosniff");
View Full Code Here


    Pair<ContentType, String> contentParams = getReturnedContentParams(args);

    OutputStreamWriter writer;
    try {
      writer = new OutputStreamWriter(response, Charsets.UTF_8);
      FetchedData result = uriFetcher.fetch(
        new ExternalReference(uri, uri, uri,
          FilePosition.startOfFile(new InputSource(uri))), "*/*");
      if (checker.check("text/css", result.getContentType()) ||
          checker.check("text/javascript", result.getContentType())) {
        renderAsJSON(
          result.getTextualContent().toString(),
          null,
          contentParams.b, mq, writer, true);
        writer.flush();
        return Pair.pair(result.getContentType(), result.getCharSet());
        }
        return null;
      } catch (UnsupportedEncodingException ex) {
        return null;
      } catch (UriFetcher.UriFetchException ex) {
View Full Code Here

    servlet = new CajolingServlet(new CajolingService(
        TestBuildInfo.getInstance(), null,
        new UriFetcher() {
          public FetchedData fetch(ExternalReference ref, String mimeType)
              throws UriFetchException {
            FetchedData data = uriContent.get(ref.getUri());
            if (data == null) {
              throw new UriFetchException(ref, mimeType);
            }
            return data;
          }
View Full Code Here

TOP

Related Classes of com.google.caja.lexer.FetchedData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.