當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。