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


Java Builder.header方法代码示例

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


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

示例1: processRequest

import javax.ws.rs.client.Invocation.Builder; //导入方法依赖的package包/类
public static Response processRequest(
    String url, String method, String payload, String authHeader) {
  Client client = ClientBuilder.newClient();
  WebTarget target = client.target(url);
  Builder builder = target.request();
  builder.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
  if (authHeader != null) {
    builder.header(HttpHeaders.AUTHORIZATION, authHeader);
  }
  return (payload != null)
      ? builder.build(method, Entity.json(payload)).invoke()
      : builder.build(method).invoke();
}
 
开发者ID:OpenLiberty,项目名称:sample-acmegifts,代码行数:14,代码来源:LoginResourceTest.java

示例2: prepareRequest

import javax.ws.rs.client.Invocation.Builder; //导入方法依赖的package包/类
private Builder prepareRequest(Request request) {
    
    WebTarget webTarget = _client.target(request.getUri());
    Map<String, String> queryParams = request.getQueryParams();
    if (queryParams != null) {
        for (Entry<String, String> param : queryParams.entrySet()) {
            webTarget = webTarget.queryParam(param.getKey(), param.getValue());
        }
    }
    Map<String, Object> pathTemplateParams = request.getPathTemplateParams();
    if (pathTemplateParams != null) {
        webTarget = webTarget.resolveTemplates(pathTemplateParams);
    }
    Builder builder = webTarget.request();
    for (Cookie currCookie : request.getCookies()) {
        builder = builder.cookie(currCookie);
    }
    for (Entry<String, Object> currEntry : request.getHeaders().entrySet()) {
        builder = builder.header(currEntry.getKey(), currEntry.getValue());
    }
    
    return builder;
}
 
开发者ID:Verigreen,项目名称:verigreen,代码行数:24,代码来源:RestClientImpl.java

示例3: processRequest

import javax.ws.rs.client.Invocation.Builder; //导入方法依赖的package包/类
public Response processRequest(String url, String method, String payload, String authHeader) {
  Client client = ClientBuilder.newClient();
  WebTarget target = client.target(url);
  Builder builder = target.request();
  builder.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
  if (authHeader != null) {
    builder.header(HttpHeaders.AUTHORIZATION, authHeader);
  }
  return (payload != null)
      ? builder.build(method, Entity.json(payload)).invoke()
      : builder.build(method).invoke();
}
 
开发者ID:OpenLiberty,项目名称:sample-acmegifts,代码行数:13,代码来源:UserResourceTest.java

示例4: processRequest

import javax.ws.rs.client.Invocation.Builder; //导入方法依赖的package包/类
public Response processRequest(String url, String method, String payload)
    throws GeneralSecurityException, IOException {
  Client client = ClientBuilder.newClient();
  WebTarget target = client.target(url);
  Builder builder = target.request();
  builder.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
  builder.header(
      HttpHeaders.AUTHORIZATION,
      "Bearer "
          + new JWTVerifier()
              .createJWT("fred", new HashSet<String>(Arrays.asList("orchestrator"))));
  return (payload != null)
      ? builder.build(method, Entity.json(payload)).invoke()
      : builder.build(method).invoke();
}
 
开发者ID:OpenLiberty,项目名称:sample-acmegifts,代码行数:16,代码来源:NotificationTest.java

示例5: processRequest

import javax.ws.rs.client.Invocation.Builder; //导入方法依赖的package包/类
private Response processRequest(String url, String method, String payload, String authHeader) {
  Client client = ClientBuilder.newClient();
  WebTarget target = client.target(url);
  Builder builder = target.request();
  builder.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
  if (authHeader != null) {
    builder.header(HttpHeaders.AUTHORIZATION, authHeader);
  }
  return (payload != null)
      ? builder.build(method, Entity.json(payload)).invoke()
      : builder.build(method).invoke();
}
 
开发者ID:OpenLiberty,项目名称:sample-acmegifts,代码行数:13,代码来源:JWTVerifier.java

示例6: processRequest

import javax.ws.rs.client.Invocation.Builder; //导入方法依赖的package包/类
public static Response processRequest(
    String url, String method, String payload, String authHeader) {
  Client client = ClientBuilder.newClient();
  WebTarget target = client.target(url);
  Builder builder = target.request();
  if (payload != null) {
    builder.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
  }
  if (authHeader != null) {
    builder.header(HttpHeaders.AUTHORIZATION, authHeader);
  }
  return (payload != null)
      ? builder.build(method, Entity.json(payload)).invoke()
      : builder.build(method).invoke();
}
 
开发者ID:OpenLiberty,项目名称:sample-acmegifts,代码行数:16,代码来源:AuthResourceTest.java

示例7: getBuilder

import javax.ws.rs.client.Invocation.Builder; //导入方法依赖的package包/类
private Builder getBuilder(String path) {
	Client client = ClientBuilder.newClient();
	WebTarget target = client.target(openFireAddress).path(path);
	Builder request = target.request(MediaType.APPLICATION_XML);
	request.header("Authorization", openFireToken);
	return request;
}
 
开发者ID:SoapboxRaceWorld,项目名称:soapbox-race-core,代码行数:8,代码来源:OpenFireRestApiCli.java

示例8: request

import javax.ws.rs.client.Invocation.Builder; //导入方法依赖的package包/类
public Builder request(final WebTarget target) throws PulsarAdminException {
    try {
        Builder builder = target.request(MediaType.APPLICATION_JSON);
        // Add headers for authentication if any
        if (auth != null && auth.getAuthData().hasDataForHttp()) {
            for (Map.Entry<String, String> header : auth.getAuthData().getHttpHeaders()) {
                builder.header(header.getKey(), header.getValue());
            }
        }
        return builder;
    } catch (Throwable t) {
        throw new GettingAuthenticationDataException(t);
    }
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:15,代码来源:BaseResource.java

示例9: addHeaders

import javax.ws.rs.client.Invocation.Builder; //导入方法依赖的package包/类
private void addHeaders(HttpServletRequest request, Builder requestBuilder) {
	Enumeration<String> headerNames = request.getHeaderNames();
	while (headerNames.hasMoreElements()) {
		String key = headerNames.nextElement();
		requestBuilder.header(key, request.getHeader(key));
	}
}
 
开发者ID:Mockenize,项目名称:mockenize-server,代码行数:8,代码来源:ProxyService.java

示例10: will_fail_on_init

import javax.ws.rs.client.Invocation.Builder; //导入方法依赖的package包/类
@Test
public void will_fail_on_init(@ArquillianResteasyResource("resources/webhook") WebTarget target) {
    String data = "This our important content to be sent";
    String secret = "password4tests";
    
    final Builder request = target.request(MediaType.TEXT_PLAIN);
    request.header("X-Hub-Signature", XHub.generateHeaderXHubToken(XHubConverter.HEXA_LOWERCASE, XHubDigest.SHA1, secret, data.getBytes()));
    
    Response resp = request.post(Entity.text(data));
    assertThat(resp, notNullValue());
    assertThat(resp.getStatus(), is(Status.INTERNAL_SERVER_ERROR.getStatusCode()));
    resp.close();
}
 
开发者ID:McFoggy,项目名称:xhub4j,代码行数:14,代码来源:ServletWithPredefinedFailingWebXmlIT.java

示例11: a_post_with_expected_signature_passes_the_filter

import javax.ws.rs.client.Invocation.Builder; //导入方法依赖的package包/类
@Test
public void a_post_with_expected_signature_passes_the_filter(@ArquillianResteasyResource("resources/webhook") WebTarget target) {
    String data = "This our important content to be sent";
    String secret = "password4tests";
    
    final Builder request = target.request(MediaType.TEXT_PLAIN);
    request.header("X-Hub-Signature", XHub.generateHeaderXHubToken(XHubConverter.HEXA_LOWERCASE, XHubDigest.SHA1, secret, data.getBytes()));
    
    Response resp = request.post(Entity.text(data));
    assertThat(resp, notNullValue());
    assertThat(resp.getStatus(), is(Status.ACCEPTED.getStatusCode()));
    resp.close();
}
 
开发者ID:McFoggy,项目名称:xhub4j,代码行数:14,代码来源:BaseServletWebHookTester.java

示例12: a_post_with_signature_with_wrong_password_fails

import javax.ws.rs.client.Invocation.Builder; //导入方法依赖的package包/类
@Test
public void a_post_with_signature_with_wrong_password_fails(@ArquillianResteasyResource("resources/webhook") WebTarget target) {
    String data = "This our important content to be sent";
    String secret = "modified-password4tests";
    
    final Builder request = target.request(MediaType.TEXT_PLAIN);
    request.header("X-Hub-Signature", XHub.generateHeaderXHubToken(XHubConverter.HEXA_LOWERCASE, XHubDigest.SHA1, secret, data.getBytes()));
    
    Response resp = request.post(Entity.text(data));
    assertThat(resp, notNullValue());
    assertThat(resp.getStatus(), is(Status.INTERNAL_SERVER_ERROR.getStatusCode()));
    resp.close();
}
 
开发者ID:McFoggy,项目名称:xhub4j,代码行数:14,代码来源:BaseServletWebHookTester.java

示例13: a_post_with_signature_with_wrong_converter_fails

import javax.ws.rs.client.Invocation.Builder; //导入方法依赖的package包/类
@Test
public void a_post_with_signature_with_wrong_converter_fails(@ArquillianResteasyResource("resources/webhook") WebTarget target) {
    String data = "This our important content to be sent";
    String secret = "password4tests";
    
    final Builder request = target.request(MediaType.TEXT_PLAIN);
    request.header("X-Hub-Signature", XHub.generateHeaderXHubToken(XHubConverter.HEXA, XHubDigest.SHA1, secret, data.getBytes()));
    
    Response resp = request.post(Entity.text(data));
    assertThat(resp, notNullValue());
    assertThat(resp.getStatus(), is(Status.INTERNAL_SERVER_ERROR.getStatusCode()));
    resp.close();
}
 
开发者ID:McFoggy,项目名称:xhub4j,代码行数:14,代码来源:BaseServletWebHookTester.java

示例14: a_post_with_signature_with_SH256_digest_succeed

import javax.ws.rs.client.Invocation.Builder; //导入方法依赖的package包/类
@Test
public void a_post_with_signature_with_SH256_digest_succeed(@ArquillianResteasyResource("resources/webhook") WebTarget target) {
    String data = "This our important content to be sent";
    String secret = "password4tests";
    
    final Builder request = target.request(MediaType.TEXT_PLAIN);
    request.header("X-Hub-Signature", XHub.generateHeaderXHubToken(XHubConverter.HEXA_LOWERCASE, XHubDigest.SHA256, secret, data.getBytes()));
    
    Response resp = request.post(Entity.text(data));
    assertThat(resp, notNullValue());
    assertThat(resp.getStatus(), is(Status.ACCEPTED.getStatusCode()));
    resp.close();
}
 
开发者ID:McFoggy,项目名称:xhub4j,代码行数:14,代码来源:BaseServletWebHookTester.java

示例15: a_post_with_signature_with_SHA512_digest_succeed

import javax.ws.rs.client.Invocation.Builder; //导入方法依赖的package包/类
@Test
public void a_post_with_signature_with_SHA512_digest_succeed(@ArquillianResteasyResource("resources/webhook") WebTarget target) {
    String data = "This our important content to be sent";
    String secret = "password4tests";
    
    final Builder request = target.request(MediaType.TEXT_PLAIN);
    request.header("X-Hub-Signature", XHub.generateHeaderXHubToken(XHubConverter.HEXA_LOWERCASE, XHubDigest.SHA512, secret, data.getBytes()));
    
    Response resp = request.post(Entity.text(data));
    assertThat(resp, notNullValue());
    assertThat(resp.getStatus(), is(Status.ACCEPTED.getStatusCode()));
    resp.close();
}
 
开发者ID:McFoggy,项目名称:xhub4j,代码行数:14,代码来源:BaseServletWebHookTester.java


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