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


Java BoundRequestBuilder.addHeader方法代码示例

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


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

示例1: createUploadArticle

import org.asynchttpclient.BoundRequestBuilder; //导入方法依赖的package包/类
public ArticleAttachments createUploadArticle(long articleId, File file, boolean inline) throws IOException {
    BoundRequestBuilder builder = client.preparePost(tmpl("/help_center/articles/{id}/attachments.json").set("id", articleId).toString());
    if (realm != null) {
        builder.setRealm(realm);
    } else {
        builder.addHeader("Authorization", "Bearer " + oauthToken);
    }
    builder.setHeader("Content-Type", "multipart/form-data");

    if (inline)
        builder.addBodyPart(new StringPart("inline", "true"));

  builder.addBodyPart(
        new FilePart("file", file, "application/octet-stream", Charset.forName("UTF-8"), file.getName()));
    final Request req = builder.build();
    return complete(submit(req, handle(ArticleAttachments.class, "article_attachment")));
}
 
开发者ID:cloudbees,项目名称:zendesk-java-client,代码行数:18,代码来源:Zendesk.java

示例2: performRequest

import org.asynchttpclient.BoundRequestBuilder; //导入方法依赖的package包/类
private JsonObject performRequest(BoundRequestBuilder requestBuilder,
    JsonObject body,
    int expectedStatusCode,
    String errorMessage)
    throws StashClientException {

  if (body != null) {
    requestBuilder.setBody(body.toJson());
  }
  addAuth(requestBuilder);
  requestBuilder.setFollowRedirect(true);
  requestBuilder.addHeader("Content-Type", JSON.toString());
  requestBuilder.addHeader("Accept", JSON.toString());

  Request request = requestBuilder.build();
  MDC.put(MDC_URL_KEY, request.getUrl());
  MDC.put(MDC_METHOD_KEY, request.getMethod());

  try {
    Response response = httpClient.executeRequest(request).get(stashTimeout, TimeUnit.MILLISECONDS);
    validateResponse(response, expectedStatusCode, errorMessage);
    return extractResponse(response);

  } catch (ExecutionException | TimeoutException | InterruptedException e) {
    throw new StashClientException(e);
  } finally {
    MDC.remove(MDC_URL_KEY);
    MDC.remove(MDC_METHOD_KEY);
  }
}
 
开发者ID:AmadeusITGroup,项目名称:sonar-stash,代码行数:31,代码来源:StashClient.java


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