Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.qiniu.android.http;
 
 import  org.apache.http.message.BasicHeader;
 import  org.apache.http.Header;

Report the client status to Server.
 
 public final class StatReport implements IReport{
    private ResponseInfo previousErrorInfo = null;
    private ResponseInfo previousSpeedInfo = null;

    
Convert response info to Server Header

Parameters:
headers origin headers
Returns:
header
    public synchronized Header[] appendStatHeaders(Header[] headers) {
        if ( == null &&  == null) {
            return headers;
        }
        int count = 1;
        if ( != null &&  != null) {
            count = 2;
        }
        Header[] h;
        h = new Header[headers.length + count];
        System.arraycopy(headers, 0, h, 0, headers.length);
        if ( != null) {
            ResponseInfo einfo = ;
            String reqId = einfo.reqId != null ? einfo.reqId : "";
            String cdnId = einfo.xvia != null ? einfo.xvia : "";
            h[headers.length] = new BasicHeader("X-Estat",
                    String.format("e1;%d;%s;%s;%s;%f",
                            einfo.statusCodereqIdcdnIdeinfo.ipeinfo.duration));
             = null//clear the error
        }
        if ( != null) {
            h[headers.length + count - 1] = new BasicHeader("X-Stat",
                    String.format("v1;%s;%f;%s;%s".,
                            ..,
                            .));
        }
        return h;
    }
    public synchronized void updateErrorInfo(ResponseInfo info) {
         = info;
    }
    public synchronized void updateSpeedInfo(ResponseInfo info) {
         = info;
    }
New to GrepCode? Check out our FAQ X