internal static HttpRequestMessage Deserialize(CachedRequest cachedRequest) { var request = new HttpRequestMessage { Method = new HttpMethod(cachedRequest.Method), RequestUri = new Uri(cachedRequest.Uri), }; foreach (var kvp in cachedRequest.Headers) { if (IsValidHeader(kvp.Key)) { request.Headers.Add(kvp.Key, kvp.Value); } } request.Content = SetContent(cachedRequest.Body, ""); return(request); }
static bool MatchesRequest(CachedRequest cached, CachedRequest fresh) { if (!string.Equals(cached.Method, fresh.Method, StringComparison.OrdinalIgnoreCase)) { return(false); } if (cached.Uri != fresh.Uri) { return(false); } if (cached.Body.Text != fresh.Body.Text) { return(false); } cached.Headers.TryGetValue("auth-token", out var cachedToken); fresh.Headers.TryGetValue("auth-token", out var freshToken); if (cachedToken != freshToken) { return(false); } return(true); }