本文整理匯總了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);
}