@Test public void testUserAgent_default() throws IOException { Interceptor.Chain chain = mock(Interceptor.Chain.class); Request request = new Request.Builder().url("http: when(chain.request()).thenReturn(request); interceptor.intercept(chain); verify(chain).request(); ArgumentCaptor<Request> argument = ArgumentCaptor.forClass(Request.class); verify(chain).proceed(argument.capture()); assertThat(argument.getValue().header("User-Agent")).isEqualTo(UserAgents.format(USER_AGENT)); }
@Override public Response intercept(Chain chain) throws IOException { Request originalRequest = chain.request(); Request requestWithUserAgent = originalRequest.newBuilder().header("User-Agent", userAgent).build(); return chain.proceed(requestWithUserAgent); }
UserAgentInterceptor implements Interceptor { @Override public Response intercept(Chain chain) throws IOException { Request originalRequest = chain.request(); Request requestWithUserAgent = originalRequest.newBuilder().header("User-Agent", userAgent).build(); return chain.proceed(requestWithUserAgent); } }
UserAgentInterceptor implements Interceptor { @Override public Response intercept(Chain chain) throws IOException { Request originalRequest = chain.request(); Request requestWithUserAgent = originalRequest.newBuilder().header("User-Agent", userAgent).build(); return chain.proceed(requestWithUserAgent); } private  UserAgentInterceptor(UserAgent userAgent); }
UserAgentInterceptor implements Interceptor { @Override public Response intercept(Chain chain) throws IOException { Request originalRequest = chain.request(); Request requestWithUserAgent = originalRequest.newBuilder().header("User-Agent", userAgent).build(); return chain.proceed(requestWithUserAgent); } private  UserAgentInterceptor(UserAgent userAgent); static UserAgentInterceptor of(UserAgent userAgent); @Override Response intercept(Chain chain); }
UserAgentInterceptor implements Interceptor { @Override public Response intercept(Chain chain) throws IOException { Request originalRequest = chain.request(); Request requestWithUserAgent = originalRequest.newBuilder().header("User-Agent", userAgent).build(); return chain.proceed(requestWithUserAgent); } private  UserAgentInterceptor(UserAgent userAgent); static UserAgentInterceptor of(UserAgent userAgent); @Override Response intercept(Chain chain);  }