• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java FluentCaseInsensitiveStringsMap类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.ning.http.client.FluentCaseInsensitiveStringsMap的典型用法代码示例。如果您正苦于以下问题:Java FluentCaseInsensitiveStringsMap类的具体用法?Java FluentCaseInsensitiveStringsMap怎么用?Java FluentCaseInsensitiveStringsMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: executeString

import com.ning.http.client.FluentCaseInsensitiveStringsMap; //导入依赖的package包/类
private Promise<Response> executeString(String method, String body) {
    FluentCaseInsensitiveStringsMap headers = new FluentCaseInsensitiveStringsMap(this.headers);

    // Detect and maybe add charset
    String contentType = headers.getFirstValue(HttpHeaders.Names.CONTENT_TYPE);
    if (contentType == null) {
        contentType = "text/plain";
    }
    String charset = AsyncHttpProviderUtils.parseCharset(contentType);
    if (charset == null) {
        charset = "utf-8";
        headers.replace(HttpHeaders.Names.CONTENT_TYPE, contentType + "; charset=utf-8");
    }

    WSRequest req = new WSRequest(method).setBody(body)
            .setUrl(url)
            .setHeaders(headers)
            .setQueryParameters(new FluentStringsMap(queryParameters))
            .setBodyEncoding(charset);
    return execute(req);
}
 
开发者ID:vangav,项目名称:vos_backend,代码行数:22,代码来源:WS.java


示例2: executeString

import com.ning.http.client.FluentCaseInsensitiveStringsMap; //导入依赖的package包/类
private CompletableFuture<RestResponse> executeString(String body) {
    FluentCaseInsensitiveStringsMap headers = new FluentCaseInsensitiveStringsMap(this.headers);

    // Detect and maybe add charset
    String contentType = headers.getFirstValue(HttpHeaders.Names.CONTENT_TYPE);
    if (contentType == null) {
        contentType = "text/plain";
    }
    String charset = AsyncHttpProviderUtils.parseCharset(contentType);
    if (charset == null) {
        charset = "utf-8";
        headers.replace(HttpHeaders.Names.CONTENT_TYPE, contentType + "; charset=utf-8");
    }

    byte[] bodyBytes;
    try {
        bodyBytes = body.getBytes(charset);
    } catch (UnsupportedEncodingException e) {
        throw new RuntimeException(e);
    }

    NingRestRequest req = new NingRestRequest(client, method, url, queryParameters, headers, bodyBytes)
            .setBody(body)
            .setBodyEncoding(charset);
    return execute(req);
}
 
开发者ID:mcoira,项目名称:async-rest-client,代码行数:27,代码来源:NingRestRequestHolder.java


示例3: executeJson

import com.ning.http.client.FluentCaseInsensitiveStringsMap; //导入依赖的package包/类
private CompletableFuture<RestResponse> executeJson(JsonNode body) {
    FluentCaseInsensitiveStringsMap headers = new FluentCaseInsensitiveStringsMap(this.headers);
    headers.replace(HttpHeaders.Names.CONTENT_TYPE, "application/json; charset=utf-8");
    String bodyStr = Json.stringify(body);
    byte[] bodyBytes;
    try {
        bodyBytes = bodyStr.getBytes("utf-8");
    } catch (UnsupportedEncodingException e) {
        throw new RuntimeException(e);
    }

    NingRestRequest req = new NingRestRequest(client, method, url, queryParameters, headers, bodyBytes)
            .setBody(bodyStr)
            .setBodyEncoding("utf-8");
    return execute(req);

}
 
开发者ID:mcoira,项目名称:async-rest-client,代码行数:18,代码来源:NingRestRequestHolder.java


示例4: calculateSignature

import com.ning.http.client.FluentCaseInsensitiveStringsMap; //导入依赖的package包/类
public static void calculateSignature(Signer signer, Request request, RequestBuilderBase<?> requestBuilder) {
    RequestContent.Builder sigBuilder = new RequestContent.Builder();

    sigBuilder.setRequestTarget(request.getMethod(), getRequestPath(request));
    for (FluentCaseInsensitiveStringsMap.Entry<String, List<String>> entry : request.getHeaders().entrySet()) {
        for (String value : entry.getValue()) {
            sigBuilder.addHeader(entry.getKey(), value);
        }
    }

    if (sigBuilder.build().getDate() == null) {
        sigBuilder.addDateNow();
        requestBuilder.addHeader(Constants.HEADER_DATE, sigBuilder.build().getDate());
    }

    Authorization authz = signer.sign(sigBuilder.build());
    if (authz != null) {
        requestBuilder.setHeader(Constants.AUTHORIZATION, authz.getHeaderValue());
    }
}
 
开发者ID:adamcin,项目名称:httpsig-java,代码行数:21,代码来源:AsyncUtil.java


示例5: testLogRemoteRequest

import com.ning.http.client.FluentCaseInsensitiveStringsMap; //导入依赖的package包/类
@Test
public void testLogRemoteRequest() {
    Request req = mock(Request.class);
    when(req.getUri()).thenReturn(Uri.create("http://test.yahoo.com"));
    when(req.getHeaders()).thenReturn(new FluentCaseInsensitiveStringsMap());
    Response resp = mock(Response.class);
    when(resp.getHeader(anyString())).thenReturn("mock resp header");
    when(resp.getHeader("content-length")).thenReturn("100");

    String reqStatus = "test_status";
    ParsecAsyncProgress progress = new ParsecAsyncProgress();

    ParsecClientProfilingLogUtil.logRemoteRequest(req, resp, reqStatus, progress);
    ParsecClientProfilingLogUtil.logRemoteRequest(req, null, reqStatus, progress);
}
 
开发者ID:yahoo,项目名称:parsec-libraries,代码行数:16,代码来源:ParsecClientProfilingLogUtilTest.java


示例6: setHeader

import com.ning.http.client.FluentCaseInsensitiveStringsMap; //导入依赖的package包/类
protected void setHeader(BoundRequestBuilder builder) {
    FluentCaseInsensitiveStringsMap header = new FluentCaseInsensitiveStringsMap();
    header.add("Accept", "application/json");
    header.add("Authorization", "BEARER " + oAuthToken.getAccessToken());
    header.add("x-ddc-client-id", config.get("x-ddc-client-id"));
    
    header.add("UserClient", "salesforce-datacom-api-java-client-v1");
    
    builder.setHeaders(header);
}
 
开发者ID:forcedotcom,项目名称:salesforce-datacom-api-java-client,代码行数:11,代码来源:AbstractService.java


示例7: testGet

import com.ning.http.client.FluentCaseInsensitiveStringsMap; //导入依赖的package包/类
@Test
public void testGet() throws Exception {
    FluentCaseInsensitiveStringsMap responseHeaders = new FluentCaseInsensitiveStringsMap();

    responseHeaders.add("header1", "header1_value1");
    responseHeaders.add("header2", "header2_value1");

    List<Cookie> ningCookies = new ArrayList<>();

    ningCookies.add(new Cookie(
        "cookie1_name",
        "cookie1_value",
        false,
        null,
        "cookie1_path",
        1,
        true,
        true
    ));

    ningCookies.add(new Cookie(
        "cookie2_name",
        "cookie2_value",
        false,
        null,
        "cookie2_path",
        2,
        false,
        false
    ));

    when(mockNingResponse.getHeaders()).thenReturn(responseHeaders);
    when(mockNingResponse.getContentType()).thenReturn(MediaType.APPLICATION_JSON);
    when(mockNingResponse.getCookies()).thenReturn(ningCookies);
    when(mockNingResponse.getStatusCode()).thenReturn(200);
    when(mockNingResponse.hasResponseHeaders()).thenReturn(true);

    when(mockNingFuture.get()).thenReturn(mockNingResponse);
    when(mockNingFuture.get(anyLong(), any(TimeUnit.class))).thenReturn(mockNingResponse);

    ParsecCompletableFuture<Response> future = new ParsecCompletableFuture<>(mockNingFuture);
    Response response = future.get();

    assertEquals(response.getContentType(), MediaType.APPLICATION_JSON);
    assertEquals(response.getHeaders().size(), 2);

    response = future.get(3, TimeUnit.SECONDS);

    assertEquals(response.getContentType(), MediaType.APPLICATION_JSON);
    assertEquals(response.getHeaders().size(), 2);
}
 
开发者ID:yahoo,项目名称:parsec-libraries,代码行数:52,代码来源:ParsecCompletableFutureTest.java


示例8: setHeaders

import com.ning.http.client.FluentCaseInsensitiveStringsMap; //导入依赖的package包/类
/**
 * Defines the request headers.
 */
@Override
public WSRequest setHeaders(FluentCaseInsensitiveStringsMap hdrs) {
    headers = (headers == null ? new FluentCaseInsensitiveStringsMap() : headers);
    return super.setHeaders(hdrs);
}
 
开发者ID:vangav,项目名称:vos_backend,代码行数:9,代码来源:WS.java


示例9: convertHeaders

import com.ning.http.client.FluentCaseInsensitiveStringsMap; //导入依赖的package包/类
private Map<String, String> convertHeaders(FluentCaseInsensitiveStringsMap headers) {
    return headers.entrySet().stream()
            .collect(toImmutableMap(Map.Entry::getKey, e -> e.getValue().get(0)));

}
 
开发者ID:otto-de,项目名称:pact-jvm-provider-generic,代码行数:6,代码来源:ProviderClient.java


示例10: putHeader

import com.ning.http.client.FluentCaseInsensitiveStringsMap; //导入依赖的package包/类
private void putHeader(FluentCaseInsensitiveStringsMap httpRequestHeaders, String key, String value) {
    final List<String> valueList = new ArrayList<String>();
    valueList.add(value);
    httpRequestHeaders.put(key, valueList);
}
 
开发者ID:masonmei,项目名称:apm-agent,代码行数:6,代码来源:ExecuteRequestInterceptor.java


示例11: NingHttpHeaders

import com.ning.http.client.FluentCaseInsensitiveStringsMap; //导入依赖的package包/类
private NingHttpHeaders(FluentCaseInsensitiveStringsMap map) {
    this.map = map;
}
 
开发者ID:winstonli,项目名称:writelatex-git-bridge,代码行数:4,代码来源:NingHttpHeaders.java


示例12: getHeaders

import com.ning.http.client.FluentCaseInsensitiveStringsMap; //导入依赖的package包/类
@Override
public FluentCaseInsensitiveStringsMap getHeaders() {
    return map;
}
 
开发者ID:winstonli,项目名称:writelatex-git-bridge,代码行数:5,代码来源:NingHttpHeaders.java


示例13: build

import com.ning.http.client.FluentCaseInsensitiveStringsMap; //导入依赖的package包/类
public NingHttpHeaders build() {
    return new NingHttpHeaders(
            new FluentCaseInsensitiveStringsMap(map));
}
 
开发者ID:winstonli,项目名称:writelatex-git-bridge,代码行数:5,代码来源:NingHttpHeaders.java


示例14: sse

import com.ning.http.client.FluentCaseInsensitiveStringsMap; //导入依赖的package包/类
public String sse(final String path, final int count) throws Exception {
  CountDownLatch latch = new CountDownLatch(count);
  String result = client.prepareGet("http://localhost:" + port + path)
      .addHeader("Content-Type", MediaType.sse.name())
      .addHeader("last-event-id", count + "")
      .execute(new AsyncHandler<String>() {

        StringBuilder sb = new StringBuilder();

        @Override
        public void onThrowable(final Throwable t) {
          t.printStackTrace();
        }

        @Override
        public AsyncHandler.STATE onBodyPartReceived(final HttpResponseBodyPart bodyPart)
            throws Exception {
          sb.append(new String(bodyPart.getBodyPartBytes(), StandardCharsets.UTF_8));
          latch.countDown();
          return AsyncHandler.STATE.CONTINUE;
        }

        @Override
        public AsyncHandler.STATE onStatusReceived(final HttpResponseStatus responseStatus)
            throws Exception {
          assertEquals(200, responseStatus.getStatusCode());
          return AsyncHandler.STATE.CONTINUE;
        }

        @Override
        public AsyncHandler.STATE onHeadersReceived(final HttpResponseHeaders headers)
            throws Exception {
          FluentCaseInsensitiveStringsMap h = headers.getHeaders();
          assertEquals("close", h.get("Connection").get(0).toLowerCase());
          assertEquals("text/event-stream; charset=utf-8",
              h.get("Content-Type").get(0).toLowerCase());
          return AsyncHandler.STATE.CONTINUE;
        }

        @Override
        public String onCompleted() throws Exception {
          return sb.toString();
        }
      }).get();

  latch.await();
  return result;
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:49,代码来源:SseFeature.java


示例15: getHeaders

import com.ning.http.client.FluentCaseInsensitiveStringsMap; //导入依赖的package包/类
@Override
public FluentCaseInsensitiveStringsMap getHeaders() {
    return response.getHeaders();
}
 
开发者ID:AlgeFramework,项目名称:alge-core,代码行数:5,代码来源:NingResponse.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IoUtils类代码示例发布时间:2022-05-22
下一篇:
Java ECPointUtil类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap