2014-09-05 17 views
1
{ server: 'ATS/5.0.1', 
    date: 'Thu, 04 Sep 2014 05:34:16 GMT', 
    'content-type': 'image/jpeg', 
    'content-length': '47265', 
    'last-modified': 'Sat, 09 Aug 2014 07:32:06 GMT', 
    expires: 'Mon, 25 Aug 2014 06:45:37 GMT', 
    'cache-control': 'max-age=604800', 
    'load-balancing': 'web39', 
    'x-cache-status': 'HIT', 
    'accept-ranges': 'bytes', 
    age: '94784', 
    connection: 'keep-alive', 
    via: 'http/1.1 upyun (ApacheTrafficServer/5.0.1 [cHs f ])' 
} 

的ATS协议编码字段进行解码(“cHs f”),可以在http://trafficserver.apache.org/tools/via解码阿帕奇交通服务器通过标题解释,如何将这些代码由自己

应该怎样做,以在本地解码 ,在我的服务器上?

是否有任何关于编码协议的描述?

具有编码协议定义,我可以自己解码。

回答

0
var codes = {} 
codes[1] = {} 
codes[1]['title'] = "client-info Request headers received from client. Value is one of:" 
codes[1]['I'] = "If Modified Since (IMS)" 
codes[1]['C'] = "cookie" 
codes[1]['E'] = "error in request" 
codes[1]['S'] = "simple request (not conditional)" 
codes[1]['N'] = "no-cache" 
codes[2] = {} 
codes[2]['title'] = "cache-lookup Result of Traffic Server cache lookup for URL. Value is one of:" 
codes[2]['A'] = "in cache, not acceptable (a cache \"MISS\")" 
codes[2]['H'] = "in cache, fresh (a cache \"HIT\")" 
codes[2]['S'] = "in cache, stale (a cache \"MISS\")" 
codes[2]['R'] = "in cache, fresh Ram hit (a cache \"HIT\")" 
codes[2]['M'] = "miss (a cache \"MISS\")" 
codes[2][' '] = "no cache lookup performed" 
codes[3] = {} 
codes[3]['title'] = "server-info Response information received from origin server. Value is one of:" 
codes[3]['E'] = "error in response" 
codes[3][' '] = "no server connection needed" 
codes[3]['S'] = "served" 
codes[3]['N'] = "not-modified" 
codes[4] = {} 
codes[4]['title'] = "cache-fill Result of document write to cache. Value is one of:" 
codes[4]['U'] = "updated old cache copy" 
codes[4]['D'] = "cached copy deleted" 
codes[4]['W'] = "written into cache (new copy)" 
codes[4][' '] = "no cache write performed" 
codes[5] = {} 
codes[5]['title'] = "proxy-info Proxy operation result. Value is one of:" 
codes[5]['R'] = "origin server revalidated" 
codes[5][' '] = "unknown?" 
codes[5]['S'] = "served" 
codes[5]['N'] = "not-modified" 
codes[6] = {} 
codes[6]['title'] = "error-codes Value is one of:" 
codes[6]['A'] = "authorization failure" 
codes[6]['H'] = "header syntax unacceptable" 
codes[6]['C'] = "connection to server failed" 
codes[6]['T'] = "connection timed out" 
codes[6]['S'] = "server related error" 
codes[6]['D'] = "dns failure" 
codes[6]['N'] = "no error" 
codes[6]['F'] = "request forbidden" 
codes[7] = {} 
codes[7]['title'] = "tunnel-info Proxy-only service operation. Value is one of:" 
codes[7][' '] = "no tunneling" 
codes[7]['U'] = "tunneling because of url (url suggests dynamic content)" 
codes[7]['M'] = "tunneling due to a method (e.g. CONNECT)" 
codes[7]['O'] = "tunneling because cache is turned off" 
codes[7]['F'] = "tunneling due to a header field (such as presence of If-Range header)" 
codes[8] = {} 
codes[8]['title'] = "cache-type and cache-lookup cache result values (2 characters)" 
codes[8]['I'] = "icp" 
codes[8][' '] = "cache miss or no cache lookup" 
codes[8]['C'] = "cache" 
codes[9] = {} 
codes[9]['title'] = "cache-lookup-result character value is one of:" 
codes[9][' '] = "no cache lookup" 
codes[9]['S'] = "cache hit, but expired" 
codes[9]['U'] = "cache hit, but client forces revalidate (e.g. Pragma: no-cache)" 
codes[9]['D'] = "cache hit, but method forces revalidated (e.g. ftp, not anonymous)" 
codes[9]['I'] = "conditional miss (client sent conditional, fresh in cache, returned 412)" 
codes[9]['H'] = "cache hit" 
codes[9]['M'] = "cache miss (url not in cache)" 
codes[9]['C'] = "cache hit, but config forces revalidate" 
codes[9]['N'] = "conditional hit (client sent conditional, doc fresh in cache, returned 304)" 
codes[10] = {} 
codes[10]['title'] = "icp-conn-info ICP status" 
codes[10][' '] = "no icp" 
codes[10]['S'] = "connection opened successfully" 
codes[10]['F'] = "connection open failed" 
codes[11] = {} 
codes[11]['title'] = "parent-proxy parent proxy connection status" 
codes[11][' '] = "no parent proxy" 
codes[11]['S'] = "connection opened successfully" 
codes[11]['F'] = "connection open failed" 
codes[12] = {} 
codes[12]['title'] = "server-conn-info origin server connection status" 
codes[12][' '] = "no server connection" 
codes[12]['S'] = "connection opened successfully" 
codes[12]['F'] = "connection open failed" 

function showVia(form, value) { 
    var text = value? value : form.via.value; 
    if (value) { 
     document.getElementById("via").value = value; 
    } 
    var via = document.getElementById("viaoutput") 
    var output = ""; 
    var txtonly = text.match(/([a-zA-Z: ]+)/); 
    text = txtonly[1]; 
    if (text.length == 5) { 
     text = text + " " 
    } 
    if (text.length == 24) { 
     var arr = text.match(/([a-zA-Z ]+):([a-zA-Z ]+)/); 
     output = output + "<h3>Proxy request results:</h3>"; 
     output = output + '<div style="width: 450px; font-weight: bold; float: left;">Request headers received from client:</div> <font color="#003399">' + codes[1][arr[1][1]] + '</font><br/>'; 
     output = output + '<div style="width: 450px; font-weight: bold; float: left;">Result of Traffic Server cache lookup for URL:</div> <font color="#003399">' + codes[2][arr[1][3]] + '</font><br/>'; 
     output = output + '<div style="width: 450px; font-weight: bold; float: left;">Response information received from origin server:</div> <font color="#003399">' + codes[3][arr[1][5]] + '</font><br/>'; 
     output = output + '<div style="width: 450px; font-weight: bold; float: left;">Result of document write-to-cache:</div> <font color="#003399">' + codes[4][arr[1][7]] + '</font><br/>'; 
     output = output + '<div style="width: 450px; font-weight: bold; float: left;">Proxy operation result:</div> <font color="#003399">' + codes[5][arr[1][9]] + '</font><br/>'; 
     output = output + '<div style="width: 450px; font-weight: bold; float: left;">Error codes (if any):</div> <font color="#003399">' + codes[6][arr[1][11]] + '</font><br/>'; 

     output = output + "<h3>Operational results:</h3>"; 
     output = output + '<div style="width: 450px; font-weight: bold; float: left;">Tunnel info:</div> <font color="#003399">' + codes[7][arr[2][1]] + '</font><br/>'; 
     output = output + '<div style="width: 450px; font-weight: bold; float: left;">Cache-type and cache-lookup cache result values:</div> <font color="#003399">' + codes[8][arr[2][3]] + "/" + codes[9][arr[2][4]] + '</font><br/>'; 
     output = output + '<div style="width: 450px; font-weight: bold; float: left;">ICP status:</div> <font color="#003399">' + codes[10][arr[2][6]] + '</font><br/>'; 
     output = output + '<div style="width: 450px; font-weight: bold; float: left;">Parent proxy connection status:</div> <font color="#003399">' + codes[11][arr[2][8]] + '</font><br/>'; 
     output = output + '<div style="width: 450px; font-weight: bold; float: left;">Origin server connection status:</div> <font color="#003399">' + codes[12][arr[2][10]] + '</font><br/>'; 

    } else if (text.length == 6) { 
     output = output + "<h3>Proxy request results:</h3>"; 
     output = output + '<div style="width: 450px; font-weight: bold; float: left;">Result of Traffic Server cache lookup for URL:</div> <font color="#003399">' + codes[2][text[1]] + '</font><br/>'; 
     output = output + '<div style="width: 450px; font-weight: bold; float: left;">Response information received from origin server:</div> <font color="#003399">' + codes[3][text[3]] + '</font><br/>'; 
     output = output + '<div style="width: 450px; font-weight: bold; float: left;">Result of document write-to-cache:</div> <font color="#003399">' + codes[4][text[5]] + '</font><br/>'; 


    } else { 
     output = "Invalid VIA data, must be 24 or 6 characters long."; 
    } 
    via.innerHTML = output; 
    if (form) { 
     window.location.hash = escape(text); 
    } 
    return false; 
} 

function checkQuery() { 
    var url = location.href; 
    if (url.indexOf("#") > 0) { 
     var qs = url.substring(url.indexOf("#")+1).replace("%20", " ").replace("+", " "); 
     if (qs && qs.length > 5) { 
      showVia(false, qs); 
     } 
    } 
} 
0

从v5.3.0(我认为)开始,有一个新的命令行实用程序traffic_via可以解码这个头文件。例如。

% traffic_via '[cHs f ]' 
Via header is [cHs f ], Length is 8 
Via Header Details: 
Result of Traffic Server cache lookup for URL   :in cache, fresh (a cache "HIT") 
Response information received from origin server  :no server connection needed 
Result of document write-to-cache:      :no cache write performed