Package railo.commons.net.http

Examples of railo.commons.net.http.HTTPResponse


    String strUrl="http://"+bucketName+"."+host+"/"+objectName;
    if(Util.hasUpperCase(bucketName))strUrl="http://"+host+"/"+bucketName+"/"+objectName;
   
   
   
    HTTPResponse method = HTTPEngine3Impl.put(new URL(strUrl), null, null, -1,MAX_REDIRECT, null,
        "Railo", null,headers,re);
    if(method.getStatusCode()!=200){
      new ErrorFactory(method.getContentAsStream());
    }
   
   
  }
View Full Code Here


  public InputStream getInputStream(String bucketName,String objectName) throws InvalidKeyException, NoSuchAlgorithmException, IOException, SAXException  {
    return getData(bucketName, objectName).getContentAsStream();
  }
 
  public Map<String, String> getMetadata(String bucketName,String objectName) throws InvalidKeyException, NoSuchAlgorithmException, IOException, SAXException  {
    HTTPResponse method = getData(bucketName, objectName);
    Header[] headers = method.getAllHeaders();
    Map<String,String> rtn=new HashMap<String, String>();
    String name;
    if(headers!=null)for(int i=0;i<headers.length;i++){
      name=headers[i].getName();
      if(name.startsWith("x-amz-meta-"))
View Full Code Here

    String strUrl="http://"+bucketName+"."+host+"/"+objectName;
    if(Util.hasUpperCase(bucketName))strUrl="http://"+host+"/"+bucketName+"/"+objectName;
    URL url = new URL(strUrl);
   
   
    HTTPResponse method = HTTPEngine3Impl.get(url, null, null, -1,MAX_REDIRECT, null, "Railo", null,
        new Header[]{
        header("Date",dateTimeString),
        header("Host",bucketName+"."+host),
        header("Authorization","AWS "+getAccessKeyIdValidate()+":"+signature)
        }
    );
    if(method.getStatusCode()!=200)
      new ErrorFactory(method.getContentAsStream());
    return method;
  }
View Full Code Here

    String strUrl="http://"+bucketName+"."+host+"/"+objectName;
    if(Util.hasUpperCase(bucketName))strUrl="http://"+host+"/"+bucketName+"/"+objectName;
   
   
   
    HTTPResponse rsp = HTTPEngine3Impl.delete(new URL(strUrl), null, null, -1,MAX_REDIRECT, null, "Railo",  null,headers);
   
    if(rsp.getStatusCode()!=200)
      new ErrorFactory(rsp.getContentAsStream());
  }
View Full Code Here

public class TestS3 {
  public static void main(String[] args) throws Throwable {

    String accessKeyId = "1DHC5C5FVD7YEPR4DBG2";
    String secretAccessKey = "R/sOy3hgimrI8D9c0lFHchoivecnOZ8LyVmJpRFQ";
    HTTPResponse m;
   
    S3 s3=new S3(secretAccessKey, accessKeyId, TimeZoneConstants.CET);
    //raw = s3.listBucketsRaw();
    //print.o(StringUtil.replace(IOUtil.toString(raw, null),"<","\n<",false));
   
    //meta = s3.getMetadata("j878", "sub/text.txt");
    //print.o(meta);
    //meta = s3.getMetadata("j878", "sub/xxxx");
    //print.o(meta);
    //raw = s3.aclRaw("j878", null);
    //print.o(StringUtil.replace(IOUtil.toString(raw, null),"<","\n<",false));
   
   
    m = s3.head("j878", "sub/text.txt");
    aprint.o(m.getContentAsString());
    aprint.e(m.getStatusCode());
    //aprint.o(StringUtil.replace(m.getResponseBodyAsString(),"<","\n<",false));
   
    //m = s3.head("j878", null);
    //print.o(m.getResponseHeaders());
    //print.o(StringUtil.replace(m.getResponseBodyAsString(),"<","\n<",false));
View Full Code Here

   * @param content
   * @throws IOException
     */

    private static Document toDocument(StringBuffer content,IndexWriter writer, String root, URL current,long timeout) throws IOException {
      HTTPResponse rsp = HTTPEngine.get(current, null, null, timeout,HTTPEngine.MAX_REDIRECT, null, "RailoBot", null, null);
      Document doc = DocumentUtil.toDocument(content,root,current, rsp);
     
    return doc;
  }
View Full Code Here

  public InputStream getInputStream() throws IOException {
    //ResourceUtil.checkGetInputStreamOK(this);
    //provider.lock(this);
    provider.read(this);
    HTTPResponse method = getHTTPResponse(true);
    try {
      return IOUtil.toBufferedInputStream(method.getContentAsStream());
    }
    catch (IOException e) {
      //provider.unlock(this);
      throw e;
    }
View Full Code Here

    if(meta==null) {
      pc=ThreadLocalPageContext.get(pc);
      InputStream is=null;
     
      try{
        HTTPResponse rsp = HTTPEngine.get(metaURL, username, password, -1, 0, "UTF-8", USER_AGENT, proxyData, null);
        MimeType mt = getMimeType(rsp,null);
        int format = MimeType.toFormat(mt, -1);
        if(format==-1) throw new ApplicationException("cannot convert response with mime type ["+mt+"] to a CFML Object");
        is = rsp.getContentAsStream();
        Struct data = Caster.toStruct(ReqRspUtil.toObject(pc,IOUtil.toBytes(is,false),format,mt.getCharset(),null));
        Object oUDF=data.get(KeyConstants._functions,null);
        Object oAACF=data.get(ComponentPage.ACCEPT_ARG_COLL_FORMATS,null);
       
        if(oUDF!=null && oAACF!=null) {
View Full Code Here

    headers.put("accept", "application/cfml,application/json"); // application/java disabled for the moment, it is not working when we have different railo versions
   
    InputStream is=null;
    try {
      // call remote cfc
      HTTPResponse rsp = HTTPEngine.post(url, username, password, -1, 0, "UTF-8", USER_AGENT, proxyData,headers, formfields);
     
      // read result
      Header[] rspHeaders = rsp.getAllHeaders();
      MimeType mt = getMimeType(rspHeaders,null);
      int format = MimeType.toFormat(mt, -1);
      if(format==-1) {
        if(rsp.getStatusCode()!=200) {
          boolean hasMsg=false;
          String msg=rsp.getStatusText();
          for(int i=0;i<rspHeaders.length;i++){
            if(rspHeaders[i].getName().equalsIgnoreCase("exception-message")){
              msg=rspHeaders[i].getValue();
              hasMsg=true;
            }
          }
          is = rsp.getContentAsStream();
          ApplicationException ae = new ApplicationException("remote component throws the following error:"+msg);
          if(!hasMsg)ae.setAdditional(KeyImpl.init("respone-body"),IOUtil.toString(is, mt.getCharset()));
         
          throw ae;
        }
        throw new ApplicationException("cannot convert response with mime type ["+mt+"] to a CFML Object");
      }
      is = rsp.getContentAsStream();
      return ReqRspUtil.toObject(pc,IOUtil.toBytes(is,false),format,mt.getCharset(),null);
    }
    catch (IOException ioe) {
      throw Caster.toPageException(ioe);
    }
View Full Code Here

TOP

Related Classes of railo.commons.net.http.HTTPResponse

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.