本文整理汇总了Java中com.netflix.zuul.context.RequestContext.setResponseDataStream方法的典型用法代码示例。如果您正苦于以下问题:Java RequestContext.setResponseDataStream方法的具体用法?Java RequestContext.setResponseDataStream怎么用?Java RequestContext.setResponseDataStream使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.netflix.zuul.context.RequestContext
的用法示例。
在下文中一共展示了RequestContext.setResponseDataStream方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run_on_valid_response
import com.netflix.zuul.context.RequestContext; //导入方法依赖的package包/类
@Test
public void run_on_valid_response() throws Exception {
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/service1" + DEFAULT_URL);
RequestContext context = RequestContext.getCurrentContext();
context.setRequest(request);
MockHttpServletResponse response = new MockHttpServletResponse();
context.setResponseGZipped(false);
context.setResponse(response);
InputStream in = IOUtils.toInputStream("{\"basePath\":\"/\"}", StandardCharsets.UTF_8);
context.setResponseDataStream(in);
filter.run();
assertEquals("UTF-8", response.getCharacterEncoding());
assertEquals("{\"basePath\":\"/service1\"}", context.getResponseBody());
}
开发者ID:oktadeveloper,项目名称:jhipster-microservices-example,代码行数:19,代码来源:SwaggerBasePathRewritingFilterTest.java
示例2: run
import com.netflix.zuul.context.RequestContext; //导入方法依赖的package包/类
@Override
public Object run() {
RequestContext ctx = RequestContext.getCurrentContext();
Principal principal = ctx.getRequest().getUserPrincipal();
AuthUserResponse userDetails = userService.getUserInfoFromAuthEmail(principal.getName());
InputStream decryptedNoteStream = encryptionService.decryptNote(ctx.getResponseDataStream(),
userDetails.getCryptKey(),principal.getName());
ctx.setResponseDataStream(decryptedNoteStream);
ctx.setSendZuulResponse(true);
return null;
}
示例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