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


Java ClientRequestContext.setEntityStream方法代码示例

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


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

示例1: filter

import javax.ws.rs.client.ClientRequestContext; //导入方法依赖的package包/类
@Override
public void filter(ClientRequestContext clientRequestContext) throws IOException {
    String method = clientRequestContext.getMethod();
    URI uri = clientRequestContext.getUri();
    MultivaluedMap<String, Object> headers = clientRequestContext.getHeaders();
    System.out.printf("Sending %s to: %s\n", method, uri);
    System.out.printf("Headers:\n");
    for(String key : headers.keySet()) {
        System.out.printf("  %s: %s\n", key, headers.getFirst(key));
    }
    if(clientRequestContext.hasEntity()) {
        final OutputStream stream = new LoggingStream(clientRequestContext.getEntityStream());
        clientRequestContext.setEntityStream(stream);
        clientRequestContext.setProperty("client.LoggingStream", stream);
    }
}
 
开发者ID:obsidian-toaster-quickstarts,项目名称:redhat-sso,代码行数:17,代码来源:LoggingFilter.java

示例2: filter

import javax.ws.rs.client.ClientRequestContext; //导入方法依赖的package包/类
@Override
public void filter(ClientRequestContext requestContext) throws IOException {
    if (token == null) {
        throw new IOException("cannot encode with a null token");
    }
    
    forceJerseyBuffering(requestContext);
    
    Consumer<byte[]> dataInterceptor = data -> {
        if (!requestContext.getHeaders().containsKey(header)) {
            String xhubHeaderValue = XHub.generateHeaderXHubToken(getEncoder(), getHash(), token, data);
            requestContext.getHeaders().putSingle(header, xhubHeaderValue);
        }
    };
    
    requestContext.setEntityStream(new ByteArrayInterceptingOutputStream(requestContext.getEntityStream(), dataInterceptor));
}
 
开发者ID:McFoggy,项目名称:xhub4j,代码行数:18,代码来源:XHubClientRequestFilter.java

示例3: filter

import javax.ws.rs.client.ClientRequestContext; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void filter(final ClientRequestContext context) throws IOException {
    final long id = _id.incrementAndGet();
    context.setProperty(LOGGING_ID_PROPERTY, id);

    final StringBuilder b = new StringBuilder();

    printRequestLine(b, "Sending client request", id, context.getMethod(), context.getUri());
    printPrefixedHeaders(b, id, REQUEST_PREFIX, context.getStringHeaders());

    if (printEntity && context.hasEntity() && isSupportPrintType(context.getMediaType())) {
        final OutputStream stream = new LoggingStream(b, context.getEntityStream());
        context.setEntityStream(stream);
        context.setProperty(ENTITY_LOGGER_PROPERTY, stream);
        // not calling log(b) here - it will be called by the interceptor
    } else {
        log(b);
    }
}
 
开发者ID:icode,项目名称:ameba,代码行数:23,代码来源:LoggingFilter.java

示例4: filter

import javax.ws.rs.client.ClientRequestContext; //导入方法依赖的package包/类
@Override
public void filter(final ClientRequestContext context) throws IOException {
    final long id = aid.incrementAndGet();
    final StringBuilder b = new StringBuilder();

    printRequestLine(b, "Sending client request", id, context.getMethod(), context.getUri());
    printPrefixedHeaders(b, id, REQUEST_PREFIX, context.getStringHeaders());

    if (printEntity && context.hasEntity()) {
        final OutputStream stream = new LoggingStream(b, context.getEntityStream());
        context.setEntityStream(stream);
        context.setProperty(ENTITY_LOGGER_PROPERTY, stream);
        // not calling log(b) here - it will be called by the interceptor
    } else {
        log(b);
    }
}
 
开发者ID:docker-java,项目名称:docker-java,代码行数:18,代码来源:LoggingFilter.java

示例5: filter

import javax.ws.rs.client.ClientRequestContext; //导入方法依赖的package包/类
@Override
public void filter(ClientRequestContext request) throws IOException {            
    if (request.hasEntity() && isPrintable(request.getMediaType())) {
        LoggingFilterOutputStream out = new LoggingFilterOutputStream(request.getEntityStream());
        request.setEntityStream(out);
        request.setProperty(LoggingFilterOutputStream.KEY, out);
    }
}
 
开发者ID:intuit,项目名称:karate,代码行数:9,代码来源:LoggingInterceptor.java

示例6: filter

import javax.ws.rs.client.ClientRequestContext; //导入方法依赖的package包/类
@Override
public void filter(ClientRequestContext clientRequestContext) throws IOException {
    OutputStream outputStream = new FilterOutputStream(clientRequestContext.getEntityStream()) {
        @Override
        public void write(byte[] bytes, int i, int i1) throws IOException {
            if (log.isDebugEnabled()) {
                log.debug(new String(bytes, i, i1));
            }
            super.write(bytes, i, i1);
        }
    };
    clientRequestContext.setEntityStream(outputStream);
}
 
开发者ID:axibase,项目名称:atsd-api-java,代码行数:14,代码来源:RequestBodyLogger.java

示例7: wrapEntityStreamWithLogger

import javax.ws.rs.client.ClientRequestContext; //导入方法依赖的package包/类
private void wrapEntityStreamWithLogger(ClientRequestContext requestContext) {
  OutputStream entityStream = requestContext.getEntityStream();
  LoggingOutputStream loggingOutputStream = new LoggingOutputStream(entityStream);
  requestContext.setEntityStream(loggingOutputStream);
  requestContext.setProperty(LOGGING_OUTPUT_STREAM_PROPERTY, loggingOutputStream);
}
 
开发者ID:SK-EID,项目名称:smart-id-java-client,代码行数:7,代码来源:LoggingFilter.java

示例8: filter

import javax.ws.rs.client.ClientRequestContext; //导入方法依赖的package包/类
@Override
public void filter(ClientRequestContext requestContext) throws IOException {
    if (!(requestContext.getEntityStream() instanceof SavingOutputStream)) {
        requestContext.setEntityStream(new SavingOutputStream(requestContext.getEntityStream()));
    }
}
 
开发者ID:nidi3,项目名称:raml-tester,代码行数:7,代码来源:CheckingClientFilter.java


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