Package railo.commons.io.res

Examples of railo.commons.io.res.ContentType


      HTTPResponse method = HTTPEngine.get(url, authUser, authPassword, -1,HTTPEngine.MAX_REDIRECT, null, userAgent,
          ProxyDataImpl.getInstance(proxyserver, proxyport, proxyuser, proxypassword),null);
     
      // mimetype
      if(StringUtil.isEmpty(strMimetype)) {
        ContentType ct = method.getContentType();
        if(ct!=null)
          setMimetype(ct.toString());
       
      }
      InputStream is = new ByteArrayInputStream(method.getContentAsByteArray());
      try {
       
View Full Code Here


    return new ContentTypeImpl(typeSub[0],typeSub[1],mimeCharset[1]);
  }

  @Override
  public final String getCharset() {
    ContentType ct = getContentType();
    String charset=null;
    if(ct!=null)charset=ct.getCharset();
    if(!StringUtil.isEmpty(charset)) return charset;
   
    PageContext pc = ThreadLocalPageContext.get();
    if(pc!=null) return pc.getConfig().getWebCharset();
    return "ISO-8859-1";
View Full Code Here

        }
        if(!hasError && log!=null)log.info(logName,"executed");
  }
 
    private static boolean isText(HTTPResponse rsp) {
      ContentType ct = rsp.getContentType();
        if(ct==null)return true;
        String mimetype = ct.getMimeType();
        return
          mimetype == null ||  mimetype.startsWith("text") || mimetype.startsWith("application/octet-stream");
       
    }
View Full Code Here

  public static Document toDocument(StringBuffer content,String root,URL url, HTTPResponse method) throws IOException {
        if(method.getStatusCode()!=200)return null;
       
    // get type and charset
    Document doc=null;
    ContentType ct = method.getContentType();
    long len=method.getContentLength();
    String charset=ct==null?"iso-8859-1":ct.getCharset();
       
        Runtime rt = Runtime.getRuntime();
        if(len>rt.freeMemory()){
          Runtime.getRuntime().gc();
          if(len>rt.freeMemory()) return null;
        }
         
        //print.err("url:"+url+";chr:"+charset+";type:"+type);
       
        if(ct==null || ct.getMimeType()==null)  {}
        // HTML
        else if(ct.getMimeType().indexOf("text/html")!=-1) {
          Reader r=null;
          try{
            r = IOUtil.getReader(method.getContentAsStream(), charset);
            doc= HTMLDocument.getDocument(content,r);
          }
          finally{
            IOUtil.closeEL(r);
          }
        }
        // PDF
        else if(ct.getMimeType().indexOf("application/pdf")!=-1) {
          InputStream is=null;
          try{
            is=IOUtil.toBufferedInputStream(method.getContentAsStream());
            doc= PDFDocument.getDocument(content,is);
          }
          finally {
            IOUtil.closeEL(is);
          }
        }
        // DOC
        else if(ct.getMimeType().equals("application/msword")) {
          InputStream is=null;
          try{
            is=IOUtil.toBufferedInputStream(method.getContentAsStream());
            doc= WordDocument.getDocument(content,is);
          }
          finally {
            IOUtil.closeEL(is);
          }
           
        }
        // Plain
        else if(ct.getMimeType().indexOf("text/plain")!=-1) {
          Reader r=null;
          try{
            r=IOUtil.toBufferedReader(IOUtil.getReader(method.getContentAsStream(), charset));
            doc= FileDocument.getDocument(content,r);
          }
View Full Code Here

TOP

Related Classes of railo.commons.io.res.ContentType

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.