当前位置: 首页>>代码示例>>Java>>正文


Java RequestContext.getResponseDataStream方法代码示例

本文整理汇总了Java中com.netflix.zuul.context.RequestContext.getResponseDataStream方法的典型用法代码示例。如果您正苦于以下问题:Java RequestContext.getResponseDataStream方法的具体用法?Java RequestContext.getResponseDataStream怎么用?Java RequestContext.getResponseDataStream使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.netflix.zuul.context.RequestContext的用法示例。


在下文中一共展示了RequestContext.getResponseDataStream方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: run

import com.netflix.zuul.context.RequestContext; //导入方法依赖的package包/类
@Override
public Object run() {
    RequestContext requestContext = RequestContext.getCurrentContext();
    try {
        InputStream in = requestContext.getResponseDataStream();
        StringBuffer result = new StringBuffer();
        byte[] b = new byte[1024];
        for (int n; (n = in.read(b)) != -1; ) {
            result.append(new String(b, 0, n));
        }
        LOGGER.info("接口返回结果:{}", result.toString());
        requestContext.setSendZuulResponse(true);
        requestContext.setResponseStatusCode(200);
        requestContext.setResponseBody(result.toString());
    } catch (Exception e) {
        LOGGER.error("解析返回值异常:{}", e);
    }
    return null;
}
 
开发者ID:hulvyou,项目名称:spring-cloud-template,代码行数:20,代码来源:CustomZuulFilter.java

示例2: run

import com.netflix.zuul.context.RequestContext; //导入方法依赖的package包/类
public Object run() {
	try {
		RequestContext context = getCurrentContext();
		InputStream stream = context.getResponseDataStream();
		String body = StreamUtils.copyToString(stream, Charset.forName("UTF-8"));
		context.setResponseBody("Modified via setResponseBody(): "+body);
	}
	catch (IOException e) {
		rethrowRuntimeException(e);
	}
	return null;
}
 
开发者ID:spring-cloud-samples,项目名称:sample-zuul-filters,代码行数:13,代码来源:ModifyResponseBodyFilter.java

示例3: run

import com.netflix.zuul.context.RequestContext; //导入方法依赖的package包/类
public Object run() {
	try {
		RequestContext context = getCurrentContext();
		InputStream stream = context.getResponseDataStream();
		String body = StreamUtils.copyToString(stream, Charset.forName("UTF-8"));
		body = "Modified via setResponseDataStream(): " + body;
		context.setResponseDataStream(new ByteArrayInputStream(body.getBytes("UTF-8")));
	}
	catch (IOException e) {
		rethrowRuntimeException(e);
	}
	return null;
}
 
开发者ID:spring-cloud-samples,项目名称:sample-zuul-filters,代码行数:14,代码来源:ModifyResponseDataStreamFilter.java

示例4: isSuccessfulFibonacciResponse

import com.netflix.zuul.context.RequestContext; //导入方法依赖的package包/类
private boolean isSuccessfulFibonacciResponse(RequestContext context, String path) {
  return path.contains(pathInRequest())
      && context.getResponseStatusCode() == SC_OK
      && context.sendZuulResponse()
      && (context.getResponseBody() != null || context.getResponseDataStream() != null);
}
 
开发者ID:ServiceComb,项目名称:ServiceComb-Company-WorkShop,代码行数:7,代码来源:CacheUpdateFilter.java


注:本文中的com.netflix.zuul.context.RequestContext.getResponseDataStream方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。