public CacheControl readObjectFromStream(PeterO.Support.InputStream stream)
 {
     try {
     JSONObject jsonobj=new JSONObject(StreamUtility.streamToString(stream));
     CacheControl cc=new CacheControl();
     cc.cacheability=jsonobj.getInt("cacheability");
     cc.noStore=jsonobj.getBoolean("noStore");
     cc.noTransform=jsonobj.getBoolean("noTransform");
     cc.mustRevalidate=jsonobj.getBoolean("mustRevalidate");
     cc.requestTime=Int64.Parse(jsonobj.getString("requestTime"),NumberStyles.AllowLeadingSign,CultureInfo.InvariantCulture);
     cc.responseTime=Int64.Parse(jsonobj.getString("responseTime"),NumberStyles.AllowLeadingSign,CultureInfo.InvariantCulture);
     cc.maxAge=Int64.Parse(jsonobj.getString("maxAge"),NumberStyles.AllowLeadingSign,CultureInfo.InvariantCulture);
     cc.date=Int64.Parse(jsonobj.getString("date"),NumberStyles.AllowLeadingSign,CultureInfo.InvariantCulture);
     cc.code=jsonobj.getInt("code");
     cc.age=Int64.Parse(jsonobj.getString("age"),NumberStyles.AllowLeadingSign,CultureInfo.InvariantCulture);
     cc.uri=jsonobj.getString("uri");
     cc.requestMethod=jsonobj.getString("requestMethod");
     if(cc.requestMethod!=null) {
       cc.requestMethod=StringUtility.toLowerCaseAscii(cc.requestMethod);
     }
     cc.headers=new List<string>();
     JSONArray jsonarr=jsonobj.getJSONArray("headers");
     for(int i=0;i<jsonarr.Length;i++){
       string str=jsonarr.getString(i);
       if(str!=null && (i%2)!=0){
     str=StringUtility.toLowerCaseAscii(str);
     if("age".Equals(str) ||
     "connection".Equals(str) ||
     "keep-alive".Equals(str) ||
     "proxy-authenticate".Equals(str) ||
     "proxy-authorization".Equals(str) ||
     "te".Equals(str) ||
     "trailers".Equals(str) ||
     "transfer-encoding".Equals(str) ||
     "upgrade".Equals(str)){
       // Skip "age" header field and
       // hop-by-hop header fields
       i++;
       continue;
     }
       }
       cc.headers.Add(str);
     }
     return cc;
       } catch(InvalidCastException e){
     Console.WriteLine(e.StackTrace);
     return null;
       } catch(FormatException e){
     Console.WriteLine(e.StackTrace);
     return null;
       } catch (Json.InvalidJsonException e) {
     Console.WriteLine(e.StackTrace);
     return null;
       }
 }
 private static string getString(JSONObject o, string key)
 {
     try {
       return o.getString(key);
     } catch(System.Collections.Generic.KeyNotFoundException){
       return null;
     }
 }