示例#1
0
 public void CopyRequestData(RawContext rawContext)
 {
     RequestHeaders          = rawContext.RequestHeaders;
     RequestData.RequestBody = rawContext.RequestBody;
     ParseRequest(RequestData);
     if (rawContext.ModifiedRequestBody != null)
     {
         ModifiedRequestData = new RequestData {
             RequestBody = rawContext.ModifiedRequestBody
         };
         ParseRequest(ModifiedRequestData);
         RequestModified = true;
     }
 }
示例#2
0
 public void CopyResponseData(RawContext rawContext)
 {
     ResponseData.ResponseBody = rawContext.ResponseBody;
     ResponseHeaders           = rawContext.ResponseHeaders;
     ParseResponse(ResponseData);
     if (rawContext.ModifiedResponseBody != null)
     {
         ModifiedResponseData = new ResponseData()
         {
             ResponseBody = rawContext.ModifiedResponseBody
         };
         ParseResponse(ModifiedResponseData);
         ResponseModified = true;
     }
 }
示例#3
0
        public static RequestContext GetInstance(RawContext rawContext)
        {
            RequestContext result;

            if (Cache.TryGetValue(rawContext.Guid, out result))
            {
                return(result);
            }
            result             = new RequestContext();
            result._rawContext = rawContext;
            result.Guid        = rawContext.Guid;
            result.RequestTime = rawContext.RequestTime;
            result.RequestUri  = rawContext.RequestUri;
            result.ClientIp    = rawContext.ClientIp;
            result.CopyRequestData(rawContext);
            result.CopyResponseData(rawContext);

            Cache.TryAdd(rawContext.Guid, result);
            return(result);
        }