本文整理汇总了Java中com.android.volley.Request.getBody方法的典型用法代码示例。如果您正苦于以下问题:Java Request.getBody方法的具体用法?Java Request.getBody怎么用?Java Request.getBody使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.android.volley.Request
的用法示例。
在下文中一共展示了Request.getBody方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: performRequest
import com.android.volley.Request; //导入方法依赖的package包/类
@Override
public HttpResponse performRequest(Request<?> request, Map<String, String> additionalHeaders)
throws AuthFailureError {
mLastUrl = request.getUrl();
mLastHeaders = new HashMap<String, String>();
if (request.getHeaders() != null) {
mLastHeaders.putAll(request.getHeaders());
}
if (additionalHeaders != null) {
mLastHeaders.putAll(additionalHeaders);
}
try {
mLastPostBody = request.getBody();
} catch (AuthFailureError e) {
mLastPostBody = null;
}
return mResponseToReturn;
}
示例2: setEntityIfNonEmptyBody
import com.android.volley.Request; //导入方法依赖的package包/类
/**
* 如果request的请求体不为空,进行设置请求体信息
* @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);
}
}
示例3: addBodyIfExists
import com.android.volley.Request; //导入方法依赖的package包/类
private static void addBodyIfExists(HttpURLConnection connection, Request<?> request) throws
IOException, AuthFailureError {
byte[] body = request.getBody();
if (body != null) {
connection.setDoOutput(true);
connection.addRequestProperty("Content-Type", request.getBodyContentType());
DataOutputStream out = new DataOutputStream(connection.getOutputStream());
out.write(body);
out.close();
}
}
示例4: setEntityIfNonEmptyBody
import com.android.volley.Request; //导入方法依赖的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);
}
}
示例5: addBodyIfExists
import com.android.volley.Request; //导入方法依赖的package包/类
private static void addBodyIfExists(HttpURLConnection connection, Request<?> request)
throws IOException, AuthFailureError {
byte[] body = request.getBody();
if (body != null) {
connection.setDoOutput(true);
connection.addRequestProperty(HEADER_CONTENT_TYPE, request.getBodyContentType());
DataOutputStream out = new DataOutputStream(connection.getOutputStream());
out.write(body);
out.close();
}
}
示例6: createRequestBody
import com.android.volley.Request; //导入方法依赖的package包/类
private okhttp3.RequestBody createRequestBody(Request request) throws AuthFailureError {
if (request instanceof BaseRequest) {
return ((BaseRequest) request).getRequestBody();
}
final byte[] body = request.getBody();
if (body == null) {
// added empty byte array to support empty body
return okhttp3.RequestBody.create(MediaType.parse(request.getBodyContentType()), new byte[0]);
}
return okhttp3.RequestBody.create(MediaType.parse(request.getBodyContentType()), body);
}
示例7: setEntityIfNonEmptyBody
import com.android.volley.Request; //导入方法依赖的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);
}
}
示例8: createRequestBody
import com.android.volley.Request; //导入方法依赖的package包/类
private static RequestBody createRequestBody(Request r) throws AuthFailureError {
final byte[] body = r.getBody();
if (body == null) return null;
return RequestBody.create(MediaType.parse(r.getBodyContentType()), body);
}