本文整理汇总了Java中org.apache.http.client.fluent.Request.Put方法的典型用法代码示例。如果您正苦于以下问题:Java Request.Put方法的具体用法?Java Request.Put怎么用?Java Request.Put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.http.client.fluent.Request
的用法示例。
在下文中一共展示了Request.Put方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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();
}
示例3: put
import org.apache.http.client.fluent.Request; //导入方法依赖的package包/类
HttpClientResponseDTO put(final HttpClientCallDTO reqDto) throws IOException {
final Request request = Request.Put(reqDto.getUrl());
handleRequestData(request, reqDto.getHeaders(), reqDto);
return executeRequest(request, reqDto.getHeaders());
}