List of usage examples for org.apache.http.client.methods HttpEntityEnclosingRequestBase setEntity
public void setEntity(final HttpEntity entity)
From source file:com.sparkplatform.api.core.ConnectionApacheHttp.java
private static void setData(HttpEntityEnclosingRequestBase r, String body) throws SparkAPIClientException { HttpEntity data;/*from w w w. ja v a 2 s . c o m*/ try { data = new StringEntity(body); ((StringEntity) data).setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json")); r.setEntity(data); } catch (UnsupportedEncodingException e) { throw new SparkAPIClientException( "Message cannot be sent as the body is encoded in an unsupported format.", e); } }
From source file:com.volley.toolbox.HttpClientStack.java
/** * request??//from w ww. j a v a 2s . c o m * @param httpRequest * @param request * @throws AuthFailureError */ 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); } }
From source file:neal.http.impl.httpstack.HttpClientStack.java
private static void setEntityIfNonEmptyBody(HttpEntityEnclosingRequestBase httpRequest, Request<?> request) throws HttpErrorCollection.AuthFailureError { byte[] body = request.getBody(); if (body != null) { HttpEntity entity = new ByteArrayEntity(body); httpRequest.setEntity(entity); }/*from www . ja v a 2 s . c o m*/ }
From source file:com.wiyun.engine.network.Network.java
static void setUrlEncodedEntity(HttpEntityEnclosingRequestBase request, List<NameValuePair> pairs) { try {/*from ww w . java 2 s.com*/ request.setEntity(new UrlEncodedFormEntity(pairs, "utf-8")); } catch (UnsupportedEncodingException e) { } }
From source file:org.bedework.util.http.HttpUtil.java
/** Send content * * @param content the content as bytes//from www .j a va 2 s .c om * @param contentType its type * @throws HttpException if not entity enclosing request */ public static void setContent(final HttpRequestBase req, final byte[] content, final String contentType) throws HttpException { if (content == null) { return; } if (!(req instanceof HttpEntityEnclosingRequestBase)) { throw new HttpException("Invalid operation for method " + req.getMethod()); } final HttpEntityEnclosingRequestBase eem = (HttpEntityEnclosingRequestBase) req; final ByteArrayEntity entity = new ByteArrayEntity(content); entity.setContentType(contentType); eem.setEntity(entity); }
From source file:com.nxt.zyl.data.volley.toolbox.HttpClientStack.java
private static void setEntityIfNonEmptyBody(HttpEntityEnclosingRequestBase httpRequest, final Request<?> request) throws IOException, AuthFailureError { if (request instanceof MultiPartRequest) { final UploadMultipartEntity multipartEntity = ((MultiPartRequest<?>) request).getMultipartEntity(); httpRequest.setEntity(multipartEntity); } else {/*from w w w. j av a2 s .c om*/ byte[] body = request.getBody(); if (body != null) { HttpEntity entity = new ByteArrayEntity(body); httpRequest.setEntity(entity); } } }
From source file:com.zlk.bigdemo.android.volley.toolbox.HttpClientStack.java
private static void setEntityIfNonEmptyBody(HttpEntityEnclosingRequestBase httpRequest, Request<?> request) throws AuthFailureError { HttpEntity entity = request.getMultiBody(); if (entity == null) { byte[] body = request.getBody(); if (body != null) { entity = new ByteArrayEntity(body); }/*w w w. jav a2s . co m*/ } if (entity != null) { httpRequest.setEntity(entity); } }
From source file:v2.service.generic.library.utils.HttpClientUtil.java
@Deprecated public static HttpResponsePOJO jsonRequest(String url, String json, String requestType) throws Exception { HttpClient httpclient = createHttpClient(); HttpEntityEnclosingRequestBase request = null; if ("POST".equalsIgnoreCase(requestType)) { request = new HttpPost(url); } else if ("PUT".equalsIgnoreCase(requestType)) { request = new HttpPut(url); }//from www .j a v a 2 s . co m StringEntity params = new StringEntity(json, "UTF-8"); request.setEntity(params); request.addHeader("content-type", "application/json"); HttpResponsePOJO result = invoke(httpclient, request); return result; }
From source file:at.orz.arangodb.http.HttpManager.java
private static void configureBodyParams(HttpRequestEntity requestEntity, HttpEntityEnclosingRequestBase request) { if (requestEntity.entity != null) { request.setEntity(requestEntity.entity); } else if (requestEntity.bodyText != null) { request.setEntity(new StringEntity(requestEntity.bodyText, APPLICATION_JSON_UTF8)); }// ww w .j a v a2 s. c o m }
From source file:com.caibowen.gplume.misc.test.HttpClientUtil.java
public static HttpEntityEnclosingRequestBase setParam(HttpEntityEnclosingRequestBase request, Map<String, ? extends Serializable> params, Charset charset) { if (charset == null) charset = Consts.UTF_8;/*from w ww. j av a 2s . c om*/ if (params != null && params.size() > 0) { UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(getParamsList(params), charset); request.setEntity(formEntity); } return request; }