當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。