Inheritance: Qiniu.Http.HttpResult
Beispiel #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="ops"></param>
        /// <returns></returns>
        public HttpResult batch(string[] ops)
        {
            HttpResult batchResult = null;
            string batchUrl = string.Format("{0}{1}", Config.ZONE.RsHost, "/batch");

            StringBuilder opsBuilder = new StringBuilder();
            for (int i = 0; i < ops.Length; i++)
            {
                opsBuilder.AppendFormat("op={0}", ops[i]);
                if (i < ops.Length - 1)
                {
                    opsBuilder.Append("&");
                }
            }
            string accessToken = Auth.createManageToken(batchUrl, Encoding.UTF8.GetBytes(opsBuilder.ToString()), this.mac);
            Dictionary<string, string> batchHeaders = new Dictionary<string, string>();
            batchHeaders.Add("Authorization", accessToken);
            CompletionHandler batchCompletionHandler = new CompletionHandler(delegate(ResponseInfo respInfo, string response)
            {
                batchResult = new FetchResult();
                batchResult.Response = response;
                batchResult.ResponseInfo = respInfo;
            });

            Dictionary<string, string[]> batchParams = new Dictionary<string, string[]>();
            batchParams.Add("op", ops);
            this.mHttpManager.postForm(batchUrl, batchHeaders, batchParams, batchCompletionHandler);
            return batchResult;
        }
Beispiel #2
0
        public HttpResult batch(string ops)
        {
            HttpResult batchResult = null;
            string batchUrl = string.Format("{0}{1}", Config.ZONE.RsHost, "/batch");
            string accessToken = Auth.createManageToken(batchUrl, Encoding.UTF8.GetBytes(ops), this.mac);
            Dictionary<string, string> batchHeaders = new Dictionary<string, string>();
            batchHeaders.Add("Authorization", accessToken);
            CompletionHandler batchCompletionHandler = new CompletionHandler(delegate(ResponseInfo respInfo, string response)
            {
                batchResult = new FetchResult();
                batchResult.Response = response;
                batchResult.ResponseInfo = respInfo;
            });

            this.mHttpManager.postData(batchUrl, batchHeaders, Encoding.UTF8.GetBytes(ops),
                HttpManager.FORM_MIME_URLENCODED, batchCompletionHandler);
            return batchResult;
        }
 public HttpResult prefetch(string bucket, string key)
 {
     HttpResult prefetchResult = null;
     string url = string.Format("{0}{1}", Config.IOVIP_HOST, prefetchOp(bucket, key));
     string token = Auth.createManageToken(url, null, this.mac);
     HttpManager httpManager = new HttpManager();
     httpManager.setAuthHeader(token);
     httpManager.CompletionHandler = new CompletionHandler(delegate(ResponseInfo respInfo, string response)
     {
         prefetchResult = new FetchResult();
         prefetchResult.Response = response;
         prefetchResult.ResponseInfo = respInfo;
     });
     httpManager.post(url);
     return prefetchResult;
 }
 public FetchResult fetch(string remoteResUrl, string bucket, string key)
 {
     FetchResult fetchResult = null;
     string url = string.Format("{0}{1}", Config.IOVIP_HOST, fetchOp(remoteResUrl, bucket, key));
     string token = Auth.createManageToken(url, null, this.mac);
     HttpManager httpManager = new HttpManager();
     httpManager.setAuthHeader(token);
     httpManager.CompletionHandler = new CompletionHandler(delegate(ResponseInfo respInfo, string response)
     {
         if (respInfo.isOk())
         {
             fetchResult = StringUtils.jsonDecode<FetchResult>(response);
         }
         else
         {
             fetchResult = new FetchResult();
         }
         fetchResult.Response = response;
         fetchResult.ResponseInfo = respInfo;
     });
     httpManager.post(url);
     return fetchResult;
 }
 public HttpResult batch(string ops)
 {
     HttpResult batchResult = null;
     string url = string.Format("{0}{1}", Config.RS_HOST, "/batch");
     string token = Auth.createManageToken(url, Encoding.UTF8.GetBytes(ops), this.mac);
     HttpManager httpManager = new HttpManager();
     httpManager.setAuthHeader(token);
     httpManager.CompletionHandler = new CompletionHandler(delegate(ResponseInfo respInfo, string response)
     {
         batchResult = new FetchResult();
         batchResult.Response = response;
         batchResult.ResponseInfo = respInfo;
     });
     PostArgs postArgs = new PostArgs();
     postArgs.Data = Encoding.UTF8.GetBytes(ops);
     httpManager.Headers.Set(HttpRequestHeader.ContentType, "application/x-www-form-urlencoded");
     httpManager.PostArgs = postArgs;
     httpManager.postData(url);
     return batchResult;
 }
Beispiel #6
0
        public HttpResult prefetch(string bucket, string key)
        {
            HttpResult prefetchResult = null;
            string prefetchUrl = string.Format("{0}{1}", Config.ZONE.IovipHost, prefetchOp(bucket, key));
            string accessToken = Auth.createManageToken(prefetchUrl, null, this.mac);
            Dictionary<string, string> prefetchHeaders = new Dictionary<string, string>();
            prefetchHeaders.Add("Authorization", accessToken);
            CompletionHandler prefetchCompletionHandler = new CompletionHandler(delegate(ResponseInfo respInfo, string response)
            {
                prefetchResult = new FetchResult();
                prefetchResult.Response = response;
                prefetchResult.ResponseInfo = respInfo;
            });

            this.mHttpManager.postForm(prefetchUrl, prefetchHeaders, null, prefetchCompletionHandler);
            return prefetchResult;
        }
Beispiel #7
0
        public FetchResult fetch(string remoteResUrl, string bucket, string key)
        {
            FetchResult fetchResult = null;
            string fetchUrl = string.Format("{0}{1}", Config.ZONE.IovipHost, fetchOp(remoteResUrl, bucket, key));
            string accessToken = Auth.createManageToken(fetchUrl, null, this.mac);
            Dictionary<string, string> fetchHeaders = new Dictionary<string, string>();
            fetchHeaders.Add("Authorization", accessToken);
            CompletionHandler fetchCompletionHandler = new CompletionHandler(delegate(ResponseInfo respInfo, string response)
            {
                if (respInfo.isOk())
                {
                    fetchResult = StringUtils.jsonDecode<FetchResult>(response);
                }
                else
                {
                    fetchResult = new FetchResult();
                }
                fetchResult.Response = response;
                fetchResult.ResponseInfo = respInfo;
            });

            this.mHttpManager.postForm(fetchUrl, fetchHeaders, null, fetchCompletionHandler);
            return fetchResult;
        }