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


Java HttpEntityEnclosingRequestBase.setEntity方法代码示例

本文整理汇总了Java中org.apache.http.client.methods.HttpEntityEnclosingRequestBase.setEntity方法的典型用法代码示例。如果您正苦于以下问题:Java HttpEntityEnclosingRequestBase.setEntity方法的具体用法?Java HttpEntityEnclosingRequestBase.setEntity怎么用?Java HttpEntityEnclosingRequestBase.setEntity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.http.client.methods.HttpEntityEnclosingRequestBase的用法示例。


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

示例1: wrapEntity

import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; //导入方法依赖的package包/类
private HttpRequestBase wrapEntity(SdkHttpFullRequest request,
                                   HttpEntityEnclosingRequestBase entityEnclosingRequest) {

    /*
     * We should never reuse the entity of the previous request, since
     * reading from the buffered entity will bypass reading from the
     * original request content. And if the content contains InputStream
     * wrappers that were added for validation-purpose (e.g.
     * Md5DigestCalculationInputStream), these wrappers would never be
     * read and updated again after AmazonHttpClient resets it in
     * preparation for the retry. Eventually, these wrappers would
     * return incorrect validation result.
     */
    if (request.content().isPresent()) {
        HttpEntity entity = new RepeatableInputStreamRequestEntity(request);
        if (request.headers().get(HttpHeaders.CONTENT_LENGTH) == null) {
            entity = ApacheUtils.newBufferedHttpEntity(entity);
        }
        entityEnclosingRequest.setEntity(entity);
    }

    return entityEnclosingRequest;
}
 
开发者ID:aws,项目名称:aws-sdk-java-v2,代码行数:24,代码来源:ApacheHttpRequestFactory.java

示例2: addPostParams

import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; //导入方法依赖的package包/类
private void addPostParams(HttpEntityEnclosingRequestBase request) throws UnsupportedEncodingException {
    final MultipartEntityBuilder multipartBuilder = MultipartEntityBuilder.create();
    List<NameValuePair> formParams = new ArrayList<>();
    postVariables.forEach((name, values) -> values.forEach(value -> {
        if (multipart) {
            if (value.startsWith("@")) {
                File f = new File(value.substring(1));
                multipartBuilder.addBinaryBody(name, f, ContentType.DEFAULT_BINARY, f.getName());
            } else {
                multipartBuilder.addTextBody(name, value);
            }
        } else {
            formParams.add(new BasicNameValuePair(name, value));
        }
    }));
    if (multipart) {
        request.setEntity(multipartBuilder.build());
    } else {
        request.setEntity(new UrlEncodedFormEntity(formParams));
    }
}
 
开发者ID:Adobe-Consulting-Services,项目名称:curly,代码行数:22,代码来源:ActionRunner.java

示例3: post

import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; //导入方法依赖的package包/类
public void post(Context context, String url, Header[] headers, RequestParams params, String contentType, AsyncHttpResponseHandler responseHandler) {
    HttpEntityEnclosingRequestBase request = new HttpPost(url);
    if (params != null) {
        request.setEntity(paramsToEntity(params));
    }
    if (headers != null) {
        request.setHeaders(headers);
    }
    sendRequest(this.httpClient, this.httpContext, request, contentType, responseHandler, context);
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:11,代码来源:AsyncHttpClient.java

示例4: setEntityIfNonEmptyBody

import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; //导入方法依赖的package包/类
private static void setEntityIfNonEmptyBody(HttpEntityEnclosingRequestBase httpRequest,
        Request<?> request) throws AuthFailureError {
    byte[] body = request.getBody();
    if (body != null) {
        HttpEntity entity = new ByteArrayEntity(body);
        httpRequest.setEntity(entity);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:HttpClientStack.java

示例5: setEntityIfNonEmptyBody

import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; //导入方法依赖的package包/类
private static void setEntityIfNonEmptyBody(HttpEntityEnclosingRequestBase httpRequest,
                                            Request<?> request) throws AuthFailureError {
    byte[] body = request.getBody();
    if (body != null) {
        HttpEntity entity = new ByteArrayEntity(body);
        httpRequest.setEntity(entity);
    }
}
 
开发者ID:paparateam,项目名称:papara-android,代码行数:9,代码来源:PaparaHttpClientStack.java

示例6: addEntityToRequestBase

import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; //导入方法依赖的package包/类
private HttpEntityEnclosingRequestBase addEntityToRequestBase(HttpEntityEnclosingRequestBase
                                                                      requestBase, HttpEntity
        entity) {
    if (entity != null) {
        requestBase.setEntity(entity);
    }
    return requestBase;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:9,代码来源:AsyncHttpClient.java

示例7: addEntityToRequestBase

import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; //导入方法依赖的package包/类
/**
 * Applicable only to HttpRequest methods extending HttpEntityEnclosingRequestBase, which is for
 * example not DELETE
 *
 * @param entity      entity to be included within the request
 * @param requestBase HttpRequest instance, must not be null
 */
private HttpEntityEnclosingRequestBase addEntityToRequestBase(HttpEntityEnclosingRequestBase requestBase, HttpEntity entity) {
    if (entity != null) {
        requestBase.setEntity(entity);
    }

    return requestBase;
}
 
开发者ID:zqHero,项目名称:rongyunDemo,代码行数:15,代码来源:AsyncHttpClient.java

示例8: setMethodAttributes

import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; //导入方法依赖的package包/类
public static void setMethodAttributes(HttpEntityEnclosingRequestBase method,  Request request) {
if(request.getBody() != null) { 
	method.setEntity(new ByteArrayEntity(request.getBody()));
}

      if (request.getParts() != null) {
          HttpEntity re = createMultipartEntities(request.getMultipartMode(), request.getParts());
          method.setEntity(re);
      }
  	
  	setMethodAttributes((HttpRequestBase) method, request);
  }
 
开发者ID:mercadolibre,项目名称:java-restclient,代码行数:13,代码来源:HTTPCUtil.java

示例9: addParametersToPostRequest

import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; //导入方法依赖的package包/类
private HttpEntityEnclosingRequestBase addParametersToPostRequest(HttpEntityEnclosingRequestBase postRequest, List<NameValuePair> params) throws UnsupportedEncodingException {
    List<NameValuePair> nameValuePairs = params;
    if(nameValuePairs!=null){
        UrlEncodedFormEntity entity = new UrlEncodedFormEntity(nameValuePairs, "utf-8");
        entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/x-www-form-urlencoded"));
        entity.setContentEncoding("utf-8");
        postRequest.setEntity(entity);
    }
    return postRequest;
}
 
开发者ID:progress-engine,项目名称:metrika_android,代码行数:11,代码来源:RequestHelper.java

示例10: addEntityToRequestBase

import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; //导入方法依赖的package包/类
/**
 * Applicable only to HttpRequest methods extending
 * HttpEntityEnclosingRequestBase, which is for example not DELETE
 *
 * @param entity      entity to be included within the request
 * @param requestBase HttpRequest instance, must not be null
 */
private HttpEntityEnclosingRequestBase addEntityToRequestBase(
    HttpEntityEnclosingRequestBase requestBase, HttpEntity entity) {
    if (entity != null) {
        requestBase.setEntity(entity);
    }

    return requestBase;
}
 
开发者ID:13120241790,项目名称:RongCloudJcenter,代码行数:16,代码来源:SyncHttpClient.java

示例11: addEntity

import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; //导入方法依赖的package包/类
private void addEntity ( HttpEntityEnclosingRequestBase req, String contentType, byte[] o )
{
	final ByteArrayEntity input = new ByteArrayEntity ( o );
	input.setContentType ( contentType );
	req.addHeader ( "Content-Type", contentType );
	req.setEntity ( input );
}
 
开发者ID:att,项目名称:dmaap-framework,代码行数:8,代码来源:HttpClient.java

示例12: completeRequest

import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; //导入方法依赖的package包/类
/** helper function to fill  the request with header entries and posting body .
 * */
private static HttpEntityEnclosingRequestBase completeRequest(HttpEntityEnclosingRequestBase request,
    List<NameValuePair> headerEntries,
    String postingBody) throws UnsupportedEncodingException{
   if (null != completeRequest(request, headerEntries)){
    // dump the post body UTF-8 will be used as the default encoding type.
    if (null != postingBody && postingBody.length() > 0){
      HttpEntity entity = new ByteArrayEntity(postingBody.getBytes("UTF-8"));
      request.setHeader("Content-Length",  Long.toString(entity.getContentLength()));
      request.setEntity(entity);
    }
  }
  return request;
}
 
开发者ID:JasonBian,项目名称:azkaban,代码行数:16,代码来源:RestfulApiClient.java

示例13: setPayloadParams

import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; //导入方法依赖的package包/类
private void setPayloadParams(HttpEntityEnclosingRequestBase method) throws IOException
{
    if (getBodyParams() != null)
    {
        StringEntity entity = new StringEntity(getBodyParams().asFormUrlEncodedString());
        entity.setContentType("application/x-www-form-urlencoded");
        method.setEntity(entity);
    }

}
 
开发者ID:edgehosting,项目名称:jira-dvcs-connector,代码行数:11,代码来源:HttpClientOauthRequest.java

示例14: postSync

import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; //导入方法依赖的package包/类
public String postSync(String url, Header[] headers, RequestParams params,
		String contentType) {
	HttpEntityEnclosingRequestBase request = new HttpPost(generateUrl(url));
	if (params != null)
		request.setEntity(invokeParamsToEntity(params, new DefaultHttpResponseHandler()));
	if (headers != null)
		request.setHeaders(headers);
	return sendSyncRequest(getHttpClient(), getHttpContext(), request,
			contentType);
}
 
开发者ID:ccliu2015,项目名称:love,代码行数:11,代码来源:HttpManager.java

示例15: addEntityToRequestBase

import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; //导入方法依赖的package包/类
private HttpEntityEnclosingRequestBase addEntityToRequestBase(HttpEntityEnclosingRequestBase requestBase, HttpEntity entity) {
    if(entity != null){
        requestBase.setEntity(entity);
    }

    return requestBase;
}
 
开发者ID:cdkd321,项目名称:pure,代码行数:8,代码来源:FinalHttp.java


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