當前位置: 首頁>>代碼示例>>Java>>正文


Java Request.getBody方法代碼示例

本文整理匯總了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;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:19,代碼來源:MockHttpStack.java

示例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);
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:15,代碼來源:HttpClientStack.java

示例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();
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:12,代碼來源:OkHttpStack.java

示例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);
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:9,代碼來源:HttpClientStack.java

示例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();
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:12,代碼來源:HurlStack.java

示例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);
}
 
開發者ID:octaware,項目名稱:super-volley,代碼行數:13,代碼來源:OkHttp3Stack.java

示例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);
    }
}
 
開發者ID:paparateam,項目名稱:papara-android,代碼行數:9,代碼來源:PaparaHttpClientStack.java

示例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);
}
 
開發者ID:wangzhaosheng,項目名稱:publicProject,代碼行數:7,代碼來源:OkHttpStack.java


注:本文中的com.android.volley.Request.getBody方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。