Android Open Source - qiniu-android Response Info






From Project

Back to project page qiniu-android.

License

The source code is released under:

MIT License

If you think the Android project qiniu-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.qiniu.android.http;
/*from w ww .  ja va2 s. c  o  m*/

import java.util.Locale;

public final class ResponseInfo {
    public static final int InvalidArgument = -4;
    public static final int InvalidFile = -3;
    public static final int Cancelled = -2;
    public static final int NetworkError = -1;
    public final int statusCode;
    public final String reqId;
    public final String xlog;
    public final String error;

    public ResponseInfo(int statusCode, String reqId, String xlog, String error) {
        this.statusCode = statusCode;
        this.reqId = reqId;
        this.xlog = xlog;
        this.error = error;
    }

    public static ResponseInfo cancelled() {
        return new ResponseInfo(Cancelled, "", "", "cancelled by user");
    }

    public static ResponseInfo invalidArgument(String message) {
        return new ResponseInfo(InvalidArgument, "", "", message);
    }


    public static ResponseInfo fileError(Exception e) {
        return new ResponseInfo(InvalidFile, "", "", e.getMessage());
    }

    public boolean isCancelled() {
        return statusCode == Cancelled;
    }

    public boolean isOK() {
        return statusCode == 200;
    }

    public boolean isNetworkBroken() {
        return statusCode == NetworkError;
    }

    public boolean isServerError() {
        return (statusCode >= 500 && statusCode < 600 && statusCode != 579) || statusCode == 996;
    }

    public boolean needRetry() {
        return isNetworkBroken() || isServerError() || statusCode == 406;
    }

    public String toString() {
        return String.format(Locale.ENGLISH, "{ResponseInfo:%s,status:%d, reqId:%s, xlog:%s,error:%s}",
                super.toString(), statusCode, reqId, xlog, error);
    }
}




Java Source Code List

com.qiniu.android.Base64Test.java
com.qiniu.android.CrcTest.java
com.qiniu.android.EtagTest.java
com.qiniu.android.FormUploadTest.java
com.qiniu.android.HttpTest.java
com.qiniu.android.ResumeUploadTest.java
com.qiniu.android.TempFile.java
com.qiniu.android.TestConfig.java
com.qiniu.android.TestFileRecorder.java
com.qiniu.android.common.Config.java
com.qiniu.android.http.ByteArrayEntity.java
com.qiniu.android.http.CompletionHandler.java
com.qiniu.android.http.HttpManager.java
com.qiniu.android.http.PostArgs.java
com.qiniu.android.http.ProgressHandler.java
com.qiniu.android.http.ResponseHandler.java
com.qiniu.android.http.ResponseInfo.java
com.qiniu.android.storage.FormUploader.java
com.qiniu.android.storage.KeyGenerator.java
com.qiniu.android.storage.Recorder.java
com.qiniu.android.storage.ResumeUploader.java
com.qiniu.android.storage.UpCancellationSignal.java
com.qiniu.android.storage.UpCompletionHandler.java
com.qiniu.android.storage.UpProgressHandler.java
com.qiniu.android.storage.UploadManager.java
com.qiniu.android.storage.UploadOptions.java
com.qiniu.android.storage.persistent.FileRecorder.java
com.qiniu.android.utils.AsyncRun.java
com.qiniu.android.utils.Crc32.java
com.qiniu.android.utils.Etag.java
com.qiniu.android.utils.StringUtils.java
com.qiniu.android.utils.UriToFile.java
com.qiniu.android.utils.UrlSafeBase64.java