• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java HttpResponseInterceptor类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.google.api.client.http.HttpResponseInterceptor的典型用法代码示例。如果您正苦于以下问题:Java HttpResponseInterceptor类的具体用法?Java HttpResponseInterceptor怎么用?Java HttpResponseInterceptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



HttpResponseInterceptor类属于com.google.api.client.http包,在下文中一共展示了HttpResponseInterceptor类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: initialize

import com.google.api.client.http.HttpResponseInterceptor; //导入依赖的package包/类
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()));
}
 
开发者ID:googleads,项目名称:googleads-shopping-samples,代码行数:26,代码来源:LoggingHttpRequestInitializer.java


示例2: initialize

import com.google.api.client.http.HttpResponseInterceptor; //导入依赖的package包/类
/**
 * Initializes this {@link com.google.api.client.auth.oauth2.Credential} subclass. Adds an
 * additional interceptor that properly sets the default encoding of the "application/json"
 * media type to UTF-8 as required by <a href="http://www.ietf.org/rfc/rfc4627.txt">RFC 4627</a>.
 * 
 * @param request The {@link HttpRequest} to be initialized.
 */
@Override
public void initialize(HttpRequest request) throws IOException {
	// Initially, pass the initialization on to super.
	super.initialize(request);
	
	// Set the timeouts.
	request.setConnectTimeout(3 * 600000);  // 10 minutes connect timeout
	request.setReadTimeout(3 * 600000);  // 10 minutes read timeout
	
	// Add an additional interceptor.
	request.setResponseInterceptor(new HttpResponseInterceptor() {
		@Override
		public void interceptResponse(HttpResponse response) throws IOException {
			// Decode JSON as UTF-8 if no charset is specified.
			if (response.getContentType().equals("application/json") &&
				response.getMediaType() != null &&
				response.getMediaType().getCharsetParameter() == null)
			{
				response.getMediaType().setCharsetParameter(StandardCharsets.UTF_8);
			}
		}
	});
	
	// Add a custom handler for unsuccessful responses.
	request.setUnsuccessfulResponseHandler(
			new UnsuccessfulResponseHandler());
}
 
开发者ID:ambi-verse,项目名称:nlu-api-client-java,代码行数:35,代码来源:Credential.java


示例3: RetryHttpRequestInitializer

import com.google.api.client.http.HttpResponseInterceptor; //导入依赖的package包/类
/**
 * @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);
}
 
开发者ID:apache,项目名称:beam,代码行数:11,代码来源:RetryHttpRequestInitializer.java


示例4: initialize

import com.google.api.client.http.HttpResponseInterceptor; //导入依赖的package包/类
@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));
}
 
开发者ID:GoogleCloudPlatform,项目名称:bigdata-interop,代码行数:35,代码来源:ChainingHttpRequestInitializer.java


示例5: makeResponseInterceptor

import com.google.api.client.http.HttpResponseInterceptor; //导入依赖的package包/类
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);
      }
    }
  };
}
 
开发者ID:GoogleCloudPlatform,项目名称:bigdata-interop,代码行数:12,代码来源:ChainingHttpRequestInitializer.java


示例6: setInterceptor

import com.google.api.client.http.HttpResponseInterceptor; //导入依赖的package包/类
@VisibleForTesting
void setInterceptor(HttpResponseInterceptor interceptor) {
  this.interceptor = interceptor;
}
 
开发者ID:firebase,项目名称:firebase-admin-java,代码行数:5,代码来源:FirebaseUserManager.java



注:本文中的com.google.api.client.http.HttpResponseInterceptor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SimpleJmsListenerContainerFactory类代码示例发布时间:2022-05-22
下一篇:
Java ContentProgressProvider类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap