当前位置: 首页>>代码示例>>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;未经允许,请勿转载。