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


Java ClientRequestContext.getHeaders方法代码示例

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


在下文中一共展示了ClientRequestContext.getHeaders方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: withCredentials

import javax.ws.rs.client.ClientRequestContext; //导入方法依赖的package包/类
public WordPressClientFactory withCredentials(String username, String password) {
    this.clientRequestFilter = new ClientRequestFilter() {
        private final String charset = StandardCharsets.UTF_8.name();

        @Override
        public void filter(ClientRequestContext requestContext) throws IOException {

            String token = String.format("%s:%s", username, password);

            String basicAuthHeader = null;

            try {
                basicAuthHeader = "BASIC " + DatatypeConverter.printBase64Binary(token.getBytes(charset));
            }
            catch (UnsupportedEncodingException ex) {
                throw new IllegalStateException("Cannot encode with " + charset, ex);
            }

            MultivaluedMap<String, Object> headers = requestContext.getHeaders();
            headers.add("Authorization", basicAuthHeader);

            logger.trace("Added BasicAuth filter with username {}", username);
        }
    };
    return this;
}
 
开发者ID:washingtonpost,项目名称:wordpress-rest-api-java-client,代码行数:27,代码来源:WordPressClientFactory.java

示例3: filter

import javax.ws.rs.client.ClientRequestContext; //导入方法依赖的package包/类
@Override
public void filter( ClientRequestContext context ) throws IOException {

    if (debugLevel == RESTDebugLevel.NONE || debugLevel == RESTDebugLevel.TARGET_URI) {
        return;
    }

    MultivaluedMap<String, Object> reqHeaders = context.getHeaders();
    StringBuilder requestMessage = new StringBuilder();
    requestMessage.append("Sending the following request: \n");
    if ( (debugLevel & RESTDebugLevel.HEADERS) == RESTDebugLevel.HEADERS) {
        requestMessage.append(context.getMethod() + " " + context.getUri() + " \n");

        for (Entry<String, List<Object>> reqHeaderEntry : reqHeaders.entrySet()) {
            requestMessage.append(reqHeaderEntry.getKey() + ": "
                                  + Arrays.toString(reqHeaderEntry.getValue().toArray()) + " \n");
        }
    }
    if ( (debugLevel & RESTDebugLevel.BODY) == RESTDebugLevel.BODY && context.hasEntity()) {
        //log request body
        Object entity = context.getEntity();
        if (entity instanceof Form) {
            requestMessage.append("Body: " + ((Form) entity).asMap());
        } else {
            requestMessage.append("Body: " + entity.toString());
        }
    }
    log.info(requestMessage);
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:30,代码来源:RestClient.java

示例4: filter

import javax.ws.rs.client.ClientRequestContext; //导入方法依赖的package包/类
@Override
public void filter(ClientRequestContext requestContext) throws IOException {
    MultivaluedMap<String, Object> headers = requestContext.getHeaders();
    final String basicAuthentication = getBasicAuthentication();
    headers.add("Authorization", basicAuthentication);

}
 
开发者ID:jmd-stuff,项目名称:task-app,代码行数:8,代码来源:TaskAppClient.java

示例5: filter

import javax.ws.rs.client.ClientRequestContext; //导入方法依赖的package包/类
@Override
public void filter(ClientRequestContext requestContext) throws IOException {
  MultivaluedMap headers = requestContext.getHeaders();
  for (Map.Entry<String, String> entry : headersToAdd.entrySet()) {
    headers.putSingle(entry.getKey(), entry.getValue());
  }
}
 
开发者ID:SK-EID,项目名称:smart-id-java-client,代码行数:8,代码来源:ClientRequestHeaderFilter.java

示例6: filter

import javax.ws.rs.client.ClientRequestContext; //导入方法依赖的package包/类
@Override
public void filter(ClientRequestContext requestContext) throws IOException
{
    CorrelationId correlationId = CorrelationIdUtil.getId();
    if(correlationId != null){
        MultivaluedMap<String, Object> headers = requestContext.getHeaders();
        headers.put(CorrelationIdFilter.CORRELATION_ID_HEADER, Arrays.asList(correlationId.getId()));
        headers.put(CorrelationIdFilter.CORRELATION_ID_SOURCE_HEADER, Arrays.asList(correlationId.getSource()));
        headers.put(CorrelationIdFilter.CORRELATION_ID_TIME_HEADER, Arrays.asList(correlationId.getCreationTime()));
    }
}
 
开发者ID:jesty,项目名称:orientdb-microservices,代码行数:12,代码来源:CorrelationIdClientRequestFilter.java

示例7: filter

import javax.ws.rs.client.ClientRequestContext; //导入方法依赖的package包/类
@Override
public void filter(ClientRequestContext requestContext) throws IOException {
    final MultivaluedMap<String, Object> headers = requestContext.getHeaders();
    final String basicAuthentication = getBasicAuthentication();
    headers.add("Authorization", basicAuthentication);

}
 
开发者ID:projectomakase,项目名称:omakase,代码行数:8,代码来源:OmakaseClient.java

示例8: filter

import javax.ws.rs.client.ClientRequestContext; //导入方法依赖的package包/类
/**
 * Adds date and authorization headers to the request.
 *
 * @param requestContext request context.
 * @throws IOException if an I/O exception occurs.
 */
@Override
public void filter(final ClientRequestContext requestContext) throws IOException {
    final MultivaluedMap<String, Object> headers = requestContext.getHeaders();
    final ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
    final String dateHeaderValue = DateTimeFormatter.RFC_1123_DATE_TIME.format(now);
    headers.add(DATE_HEADER_NAME, dateHeaderValue);
    final String authHeaderValue = signer.get().createAuthorizationHeader(
            loginName,
            keyPair,
            now
    );
    headers.add(AUTHORIZATION_HEADER_NAME, authHeaderValue);
}
 
开发者ID:joyent,项目名称:java-http-signature,代码行数:20,代码来源:SignedRequestClientRequestFilter.java

示例9: filter

import javax.ws.rs.client.ClientRequestContext; //导入方法依赖的package包/类
@Override
public void filter(ClientRequestContext clientRequestContext) throws IOException {
    MultivaluedMap<String, Object> headers = clientRequestContext.getHeaders();
    if (credentials.getUsername() == null && credentials.getPassword() == null) {
        return;
    }
    final String basicAuthentication = getBasicAuthentication();
    headers.add("Authorization", basicAuthentication);

}
 
开发者ID:Jaspersoft,项目名称:jrs-rest-java-client,代码行数:11,代码来源:BasicAuthenticationFilter.java

示例10: filter

import javax.ws.rs.client.ClientRequestContext; //导入方法依赖的package包/类
@Override
public void filter(ClientRequestContext requestContext, ClientResponseContext responseContext) throws IOException
{
    if (requestContext == null || responseContext == null || responseContext.getStatus() != Response.Status.FOUND.getStatusCode()) {
       return;
    }

    log.debug("Processing redirect for " + requestContext.getMethod() + " " + requestContext.getUri().toASCIIString() + " to " + responseContext.getLocation().toASCIIString());

    Client inClient = requestContext.getClient();
    Object entity = requestContext.getEntity();
    MultivaluedMap<String, Object> headers = requestContext.getHeaders();
    String method = requestContext.getMethod();
    Response resp;
    if ("POST".equalsIgnoreCase(method) || "PUT".equalsIgnoreCase(method)) {
        resp = inClient.target(responseContext.getLocation())
                .request(requestContext.getMediaType())
                .headers(headers)
                .method(requestContext.getMethod(), Entity.entity(new GenericEntity<JAXBElement<?>>((JAXBElement<?>)entity) {}, NsiConstants.NSI_DDS_V1_XML));
    }
    else {
        resp = inClient.target(responseContext.getLocation())
                .request(requestContext.getMediaType())
                .headers(headers)
                .method(requestContext.getMethod());
    }

    responseContext.setEntityStream((InputStream) resp.getEntity());
    responseContext.setStatusInfo(resp.getStatusInfo());
    responseContext.setStatus(resp.getStatus());
    responseContext.getHeaders().putAll(resp.getStringHeaders());

    log.debug("Processing redirect with result " + resp.getStatus());
}
 
开发者ID:BandwidthOnDemand,项目名称:nsi-dds,代码行数:35,代码来源:RestClient.java

示例11: storeSpandId

import javax.ws.rs.client.ClientRequestContext; //导入方法依赖的package包/类
void storeSpandId(ClientRequestContext responseContext, String id) {
    System.out.println("Storing id: " + id);
    MultivaluedMap<String, Object> headers = responseContext.getHeaders();
    headers.putSingle(TRACEE_HEADER, id);
}
 
开发者ID:AdamBien,项目名称:SpanEE,代码行数:6,代码来源:SpanEEClientRequestFilter.java

示例12: filter

import javax.ws.rs.client.ClientRequestContext; //导入方法依赖的package包/类
@Override
public void filter(ClientRequestContext requestContext) throws IOException {
    MultivaluedMap<String, Object> requestHeaders = requestContext.getHeaders();
    this.headersToSet.entrySet().forEach(entry -> requestHeaders.putSingle(entry.getKey(), entry.getValue()));
}
 
开发者ID:code-obos,项目名称:servicebuilder,代码行数:6,代码来源:WebTargetRequestHeaderFilter.java

示例13: filter

import javax.ws.rs.client.ClientRequestContext; //导入方法依赖的package包/类
public void filter(ClientRequestContext requestContext) throws IOException {
	MultivaluedMap<String, Object> headers = requestContext.getHeaders();
	headers.add("Authorization", basicAuth);
}
 
开发者ID:bootique,项目名称:bootique-jersey-client,代码行数:5,代码来源:BasicAuthenticatorFactory.java

示例14: filter

import javax.ws.rs.client.ClientRequestContext; //导入方法依赖的package包/类
public void filter(ClientRequestContext requestContext) throws IOException {
    MultivaluedMap<String, Object> headers = requestContext.getHeaders();
    headers.add("Authorization", getAuthorization());
}
 
开发者ID:bootique,项目名称:bootique-jersey-client,代码行数:5,代码来源:OAuth2TokenAuthenticator.java

示例15: filter

import javax.ws.rs.client.ClientRequestContext; //导入方法依赖的package包/类
@Override
public void filter(ClientRequestContext requestContext) throws IOException {
	MultivaluedMap<String, Object> headers = requestContext.getHeaders();
	headers.putSingle(HttpHeaders.AUTHORIZATION, authHeader);
}
 
开发者ID:Mercateo,项目名称:rest-hateoas-client,代码行数:6,代码来源:AuthHeaderFilter.java


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