com.google.api.client.http.HttpResponseInterceptor Java Examples
The following examples show how to use
com.google.api.client.http.HttpResponseInterceptor.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LoggingHttpRequestInitializer.java From googleads-shopping-samples with Apache License 2.0 | 6 votes |
public void initialize(HttpRequest request) throws IOException { if (wrapped != null) { wrapped.initialize(request); } request.setLoggingEnabled(true); request.setCurlLoggingEnabled(false); request.setContentLoggingLimit(Integer.MAX_VALUE); request.setResponseInterceptor( new HttpResponseInterceptor() { private HttpResponseInterceptor wrapped = null; public void interceptResponse(HttpResponse response) throws IOException { if (wrapped != null) { wrapped.interceptResponse(response); } response.setLoggingEnabled(true); response.setContentLoggingLimit(Integer.MAX_VALUE); } public HttpResponseInterceptor setWrapped(HttpResponseInterceptor toWrap) { this.wrapped = toWrap; return this; } }.setWrapped(request.getResponseInterceptor())); }
Example #2
Source File: InstanceIdClientImpl.java From firebase-admin-java with Apache License 2.0 | 5 votes |
InstanceIdClientImpl( HttpRequestFactory requestFactory, JsonFactory jsonFactory, @Nullable HttpResponseInterceptor responseInterceptor) { this.requestFactory = checkNotNull(requestFactory); this.jsonFactory = checkNotNull(jsonFactory); this.responseInterceptor = responseInterceptor; }
Example #3
Source File: FirebaseMessagingClientImplTest.java From firebase-admin-java with Apache License 2.0 | 5 votes |
private FirebaseMessagingClientImpl initMessagingClient( MockLowLevelHttpResponse mockResponse, HttpResponseInterceptor interceptor) { MockHttpTransport transport = new MockHttpTransport.Builder() .setLowLevelHttpResponse(mockResponse) .build(); return FirebaseMessagingClientImpl.builder() .setProjectId("test-project") .setJsonFactory(Utils.getDefaultJsonFactory()) .setRequestFactory(transport.createRequestFactory()) .setChildRequestFactory(Utils.getDefaultTransport().createRequestFactory()) .setResponseInterceptor(interceptor) .build(); }
Example #4
Source File: InstanceIdClientImplTest.java From firebase-admin-java with Apache License 2.0 | 5 votes |
private static InstanceIdClientImpl initInstanceIdClient( final MockLowLevelHttpResponse mockResponse, final HttpResponseInterceptor interceptor) { MockHttpTransport transport = new MockHttpTransport.Builder() .setLowLevelHttpResponse(mockResponse) .build(); return new InstanceIdClientImpl( transport.createRequestFactory(), Utils.getDefaultJsonFactory(), interceptor); }
Example #5
Source File: RetryHttpRequestInitializer.java From beam with Apache License 2.0 | 5 votes |
/** * Visible for testing. * * @param nanoClock used as a timing source for knowing how much time has elapsed. * @param sleeper used to sleep between retries. * @param additionalIgnoredResponseCodes a list of HTTP status codes that should not be logged. */ RetryHttpRequestInitializer( NanoClock nanoClock, Sleeper sleeper, Collection<Integer> additionalIgnoredResponseCodes, HttpResponseInterceptor responseInterceptor) { this.nanoClock = nanoClock; this.sleeper = sleeper; this.ignoredResponseCodes.addAll(additionalIgnoredResponseCodes); this.responseInterceptor = responseInterceptor; this.writeTimeout = 0; }
Example #6
Source File: ChainingHttpRequestInitializer.java From hadoop-connectors with Apache License 2.0 | 5 votes |
@Override public void initialize(HttpRequest request) throws IOException { List<HttpIOExceptionHandler> ioExceptionHandlers = new ArrayList<>(); List<HttpUnsuccessfulResponseHandler> unsuccessfulResponseHandlers = new ArrayList<>(); List<HttpExecuteInterceptor> interceptors = new ArrayList<>(); List<HttpResponseInterceptor> responseInterceptors = new ArrayList<>(); for (HttpRequestInitializer initializer : initializers) { initializer.initialize(request); if (request.getIOExceptionHandler() != null) { ioExceptionHandlers.add(request.getIOExceptionHandler()); request.setIOExceptionHandler(null); } if (request.getUnsuccessfulResponseHandler() != null) { unsuccessfulResponseHandlers.add(request.getUnsuccessfulResponseHandler()); request.setUnsuccessfulResponseHandler(null); } if (request.getInterceptor() != null) { interceptors.add(request.getInterceptor()); request.setInterceptor(null); } if (request.getResponseInterceptor() != null) { responseInterceptors.add(request.getResponseInterceptor()); request.setResponseInterceptor(null); } } request.setIOExceptionHandler( makeIoExceptionHandler(ioExceptionHandlers)); request.setUnsuccessfulResponseHandler( makeUnsuccessfulResponseHandler(unsuccessfulResponseHandlers)); request.setInterceptor( makeInterceptor(interceptors)); request.setResponseInterceptor( makeResponseInterceptor(responseInterceptors)); }
Example #7
Source File: ChainingHttpRequestInitializer.java From hadoop-connectors with Apache License 2.0 | 5 votes |
private HttpResponseInterceptor makeResponseInterceptor( final Iterable<HttpResponseInterceptor> responseInterceptors) { return new HttpResponseInterceptor() { @Override public void interceptResponse(HttpResponse response) throws IOException { for (HttpResponseInterceptor interceptor : responseInterceptors) { interceptor.interceptResponse(response); } } }; }
Example #8
Source File: AbstractGoogleClientRequest.java From google-api-java-client with Apache License 2.0 | 5 votes |
/** Create a request suitable for use against this service. */ private HttpRequest buildHttpRequest(boolean usingHead) throws IOException { Preconditions.checkArgument(uploader == null); Preconditions.checkArgument(!usingHead || requestMethod.equals(HttpMethods.GET)); String requestMethodToUse = usingHead ? HttpMethods.HEAD : requestMethod; final HttpRequest httpRequest = getAbstractGoogleClient() .getRequestFactory().buildRequest(requestMethodToUse, buildHttpRequestUrl(), httpContent); new MethodOverride().intercept(httpRequest); httpRequest.setParser(getAbstractGoogleClient().getObjectParser()); // custom methods may use POST with no content but require a Content-Length header if (httpContent == null && (requestMethod.equals(HttpMethods.POST) || requestMethod.equals(HttpMethods.PUT) || requestMethod.equals(HttpMethods.PATCH))) { httpRequest.setContent(new EmptyContent()); } httpRequest.getHeaders().putAll(requestHeaders); if (!disableGZipContent) { httpRequest.setEncoding(new GZipEncoding()); } httpRequest.setResponseReturnRawInputStream(returnRawInputStream); final HttpResponseInterceptor responseInterceptor = httpRequest.getResponseInterceptor(); httpRequest.setResponseInterceptor(new HttpResponseInterceptor() { public void interceptResponse(HttpResponse response) throws IOException { if (responseInterceptor != null) { responseInterceptor.interceptResponse(response); } if (!response.isSuccessStatusCode() && httpRequest.getThrowExceptionOnExecuteError()) { throw newExceptionOnError(response); } } }); return httpRequest; }
Example #9
Source File: FirebaseProjectManagementServiceImpl.java From firebase-admin-java with Apache License 2.0 | 4 votes |
@VisibleForTesting void setInterceptor(HttpResponseInterceptor interceptor) { httpHelper.setInterceptor(interceptor); }
Example #10
Source File: HttpHelper.java From firebase-admin-java with Apache License 2.0 | 4 votes |
void setInterceptor(HttpResponseInterceptor interceptor) { this.interceptor = interceptor; }
Example #11
Source File: CryptoSigners.java From firebase-admin-java with Apache License 2.0 | 4 votes |
void setInterceptor(HttpResponseInterceptor interceptor) { this.interceptor = interceptor; }
Example #12
Source File: FirebaseUserManager.java From firebase-admin-java with Apache License 2.0 | 4 votes |
@VisibleForTesting void setInterceptor(HttpResponseInterceptor interceptor) { this.interceptor = interceptor; }
Example #13
Source File: FirebaseInstanceId.java From firebase-admin-java with Apache License 2.0 | 4 votes |
@VisibleForTesting void setInterceptor(HttpResponseInterceptor interceptor) { this.interceptor = interceptor; }
Example #14
Source File: FirebaseMessagingClientImpl.java From firebase-admin-java with Apache License 2.0 | 4 votes |
Builder setResponseInterceptor(HttpResponseInterceptor responseInterceptor) { this.responseInterceptor = responseInterceptor; return this; }
Example #15
Source File: RetryHttpRequestInitializer.java From beam with Apache License 2.0 | 4 votes |
/** * @param additionalIgnoredResponseCodes a list of HTTP status codes that should not be logged. * @param responseInterceptor HttpResponseInterceptor to be applied on all requests. May be null. */ public RetryHttpRequestInitializer( Collection<Integer> additionalIgnoredResponseCodes, @Nullable HttpResponseInterceptor responseInterceptor) { this(NanoClock.SYSTEM, Sleeper.DEFAULT, additionalIgnoredResponseCodes, responseInterceptor); }