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