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


Java Request.bodyString方法代码示例

本文整理汇总了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;
}
 
开发者ID:OpenNTF,项目名称:XPages-Fusion-Application,代码行数:25,代码来源:RestUtil.java

示例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);
}
 
开发者ID:Liangdi,项目名称:zaoshu-java-sdk,代码行数:15,代码来源:HttpUtil.java

示例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();
}
 
开发者ID:DorsetProject,项目名称:dorset-framework,代码行数:13,代码来源:ApacheHttpClient.java

示例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();
}
 
开发者ID:DorsetProject,项目名称:dorset-framework,代码行数:13,代码来源:ApacheHttpClient.java


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