@Test public void applyRegexTransform() { ResponseHeaderTransform locationHeaderDropHttps = ReplayManagerTestBase.createLocationHttpsToHttpTransform(); HeaderTransformInterceptor interceptor = newInterceptor(locationHeaderDropHttps); Map.Entry<String, String> locationHeaderBefore = new SimpleImmutableEntry<>(HttpHeaders.LOCATION, "https: Map.Entry<String, String> expectedAfter = new SimpleImmutableEntry<>(HttpHeaders.LOCATION, "http: Map.Entry<String, String> actualAfter = interceptor.transform(locationHeaderBefore); assertEquals("transformed location header", expectedAfter, actualAfter); }
protected Map.Entry<String, String> transform(Map.Entry<String, String> header) { String name = header.getKey(), value = header.getValue(); String toName = headerTransform.getNameImage().transformHeaderName(name, nameMatchRegex); String toValue = headerTransform.getValueImage().transformHeaderValue(name, valueMatchRegex, value); if (!Objects.equals(name, toName) || !Objects.equals(value, toValue)) { return new SimpleImmutableEntry<>(toName, toValue); } else { return header; } }
HeaderTransformInterceptor implements ResponseInterceptor { protected Map.Entry<String, String> transform(Map.Entry<String, String> header) { String name = header.getKey(), value = header.getValue(); String toName = headerTransform.getNameImage().transformHeaderName(name, nameMatchRegex); String toValue = headerTransform.getValueImage().transformHeaderValue(name, valueMatchRegex, value); if (!Objects.equals(name, toName) || !Objects.equals(value, toValue)) { return new SimpleImmutableEntry<>(toName, toValue); } else { return header; } } }
HeaderTransformInterceptor implements ResponseInterceptor { protected Map.Entry<String, String> transform(Map.Entry<String, String> header) { String name = header.getKey(), value = header.getValue(); String toName = headerTransform.getNameImage().transformHeaderName(name, nameMatchRegex); String toValue = headerTransform.getValueImage().transformHeaderValue(name, valueMatchRegex, value); if (!Objects.equals(name, toName) || !Objects.equals(value, toValue)) { return new SimpleImmutableEntry<>(toName, toValue); } else { return header; } } HeaderTransformInterceptor(VhsReplayManagerConfig config, ResponseHeaderTransform headerTransform); }
HeaderTransformInterceptor implements ResponseInterceptor { protected Map.Entry<String, String> transform(Map.Entry<String, String> header) { String name = header.getKey(), value = header.getValue(); String toName = headerTransform.getNameImage().transformHeaderName(name, nameMatchRegex); String toValue = headerTransform.getValueImage().transformHeaderValue(name, valueMatchRegex, value); if (!Objects.equals(name, toName) || !Objects.equals(value, toValue)) { return new SimpleImmutableEntry<>(toName, toValue); } else { return header; } } HeaderTransformInterceptor(VhsReplayManagerConfig config, ResponseHeaderTransform headerTransform); @Override HttpRespondable intercept(ParsedRequest parsedRequest, HttpRespondable httpRespondable); }
HeaderTransformInterceptor implements ResponseInterceptor { protected Map.Entry<String, String> transform(Map.Entry<String, String> header) { String name = header.getKey(), value = header.getValue(); String toName = headerTransform.getNameImage().transformHeaderName(name, nameMatchRegex); String toValue = headerTransform.getValueImage().transformHeaderValue(name, valueMatchRegex, value); if (!Objects.equals(name, toName) || !Objects.equals(value, toValue)) { return new SimpleImmutableEntry<>(toName, toValue); } else { return header; } } HeaderTransformInterceptor(VhsReplayManagerConfig config, ResponseHeaderTransform headerTransform); @Override HttpRespondable intercept(ParsedRequest parsedRequest, HttpRespondable httpRespondable);  }