### Question:
DefaultRequestPipeline implements RequestPipeline { public static HttpResponse maybeFixDriftTime(HttpResponse response) { Collection<String> dates = response.getHeaders("Date"); if (!dates.isEmpty()) { Date d = DateUtil.parseRfc1123Date(dates.iterator().next()); if (d != null) { long timestamp = d.getTime(); long currentTime = HttpUtil.getTimeSource().currentTimeMillis(); if (Math.abs(currentTime - timestamp) > responseDateDriftLimit) { HttpResponseBuilder builder = new HttpResponseBuilder(response); builder.setHeader("Date", DateUtil.formatRfc1123Date(currentTime)); response = builder.create(); } } } return response; } @Inject  DefaultRequestPipeline(HttpFetcher httpFetcher,
                                HttpCache httpCache,
                                Provider<OAuthRequest> oauthRequestProvider,
                                Provider<OAuth2Request> oauth2RequestProvider,
                                @RewriterRegistry(rewriteFlow = RewriteFlow.REQUEST_PIPELINE)
                                ResponseRewriterRegistry responseRewriterRegistry,
                                InvalidationService invalidationService,
                                @Nullable HttpResponseMetadataHelper metadataHelper); HttpResponse execute(HttpRequest request); static HttpResponse maybeFixDriftTime(HttpResponse response);  }### Answer:
@Test public void testFixedDateOk() throws Exception { int time = roundToSeconds(HttpResponseTest.timeSource.currentTimeMillis()); HttpResponse response = new HttpResponseBuilder() .addHeader( "Date", DateUtil.formatRfc1123Date(1000L * time + 1000 - DefaultRequestPipeline.DEFAULT_DRIFT_LIMIT_MS)).setCacheTtl(100) .create(); HttpResponse newResponse = DefaultRequestPipeline.maybeFixDriftTime(response); assertSame(response, newResponse); }
@Test public void testFixedDateOld() throws Exception { int time = roundToSeconds(HttpResponseTest.timeSource.currentTimeMillis()); HttpResponse response = new HttpResponseBuilder() .addHeader( "Date", DateUtil.formatRfc1123Date(1000L * time - 1000 - DefaultRequestPipeline.DEFAULT_DRIFT_LIMIT_MS)).setCacheTtl(100) .create(); response = DefaultRequestPipeline.maybeFixDriftTime(response); assertEquals(time + 100, roundToSeconds(response.getCacheExpiration())); assertEquals(DateUtil.formatRfc1123Date(HttpResponseTest.timeSource.currentTimeMillis()), response.getHeader("Date")); }
@Test public void testFixedDateNew() throws Exception { int time = roundToSeconds(HttpResponseTest.timeSource.currentTimeMillis()); HttpResponse response = new HttpResponseBuilder() .addHeader( "Date", DateUtil.formatRfc1123Date(1000L * time + 1000 + DefaultRequestPipeline.DEFAULT_DRIFT_LIMIT_MS)).setCacheTtl(100) .create(); response = DefaultRequestPipeline.maybeFixDriftTime(response); assertEquals(time + 100, roundToSeconds(response.getCacheExpiration())); assertEquals(DateUtil.formatRfc1123Date(HttpResponseTest.timeSource.currentTimeMillis()), response.getHeader("Date")); }