本文整理汇总了Java中org.apache.http.client.fluent.Request.bodyString方法的典型用法代码示例。如果您正苦于以下问题:Java Request.bodyString方法的具体用法?Java Request.bodyString怎么用?Java Request.bodyString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.http.client.fluent.Request
的用法示例。
在下文中一共展示了Request.bodyString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: put
import org.apache.http.client.fluent.Request; //导入方法依赖的package包/类
/**
* Send PUT request with authorization header
* @param url - The url of the POST request
* @param auth - String for authorization header
* @param putData - The body of the PUT
*/
public Response put(String url, String auth, JsonJavaObject putData) throws URISyntaxException, IOException, JsonException {
URI normUri = new URI(url).normalize();
Request putRequest = Request.Put(normUri);
//Add auth header
if(StringUtil.isNotEmpty(auth)) {
putRequest.addHeader("Authorization", auth);
}
//Add put data
String putDataString = JsonGenerator.toJson(JsonJavaFactory.instanceEx, putData);
if(putData != null) {
putRequest = putRequest.bodyString(putDataString, ContentType.APPLICATION_JSON);
}
Response response = executor.execute(putRequest);
return response;
}
示例2: post
import org.apache.http.client.fluent.Request; //导入方法依赖的package包/类
public static String post(KeyPair keyPair,String url,Map<String,String> query,String body) throws ApiException {
URI uri = buildUri(url,query);
if(uri == null) {
return "";
}
url = uri.toString();
log.info("post url:{}",url);
Request request = Request.Post(url);
request.bodyString(body, ContentType.parse(Constant.CONTENT_TYPE));
//request.body(new StringEntity(body,"UTF-8"));
return request(keyPair,request,Constant.METHOD_POST,query,body);
}
示例3: post
import org.apache.http.client.fluent.Request; //导入方法依赖的package包/类
private Response post(HttpRequest request) throws IOException {
Request apacheRequest = Request.Post(request.getUrl());
if (request.getBody() != null) {
ContentType ct = ContentType.create(request.getContentType().getMimeType(),
request.getContentType().getCharset());
apacheRequest.bodyString(request.getBody(), ct);
} else if (request.getBodyForm() != null) {
apacheRequest.bodyForm(buildFormBody(request.getBodyForm()));
}
prepareRequest(apacheRequest);
return apacheRequest.execute();
}
示例4: put
import org.apache.http.client.fluent.Request; //导入方法依赖的package包/类
private Response put(HttpRequest request) throws IOException {
Request apacheRequest = Request.Put(request.getUrl());
if (request.getBody() != null) {
ContentType ct = ContentType.create(request.getContentType().getMimeType(),
request.getContentType().getCharset());
apacheRequest.bodyString(request.getBody(), ct);
} else if (request.getBodyForm() != null) {
apacheRequest.bodyForm(buildFormBody(request.getBodyForm()));
}
prepareRequest(apacheRequest);
return apacheRequest.execute();
}