本文整理汇总了Java中com.ning.http.client.FluentCaseInsensitiveStringsMap.replace方法的典型用法代码示例。如果您正苦于以下问题:Java FluentCaseInsensitiveStringsMap.replace方法的具体用法?Java FluentCaseInsensitiveStringsMap.replace怎么用?Java FluentCaseInsensitiveStringsMap.replace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.ning.http.client.FluentCaseInsensitiveStringsMap
的用法示例。
在下文中一共展示了FluentCaseInsensitiveStringsMap.replace方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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);
}
示例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);
}