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; } }
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; } }
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); }