当前位置: 首页>>代码示例>>Java>>正文


Java OAuthClientRequest.getBody方法代码示例

本文整理汇总了Java中org.apache.oltu.oauth2.client.request.OAuthClientRequest.getBody方法的典型用法代码示例。如果您正苦于以下问题:Java OAuthClientRequest.getBody方法的具体用法?Java OAuthClientRequest.getBody怎么用?Java OAuthClientRequest.getBody使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.oltu.oauth2.client.request.OAuthClientRequest的用法示例。


在下文中一共展示了OAuthClientRequest.getBody方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setRequestBody

import org.apache.oltu.oauth2.client.request.OAuthClientRequest; //导入方法依赖的package包/类
private void setRequestBody(OAuthClientRequest request, String requestMethod, HttpURLConnection httpURLConnection)
        throws IOException {
    String requestBody = request.getBody();
    if (OAuthUtils.isEmpty(requestBody)) {
        return;
    }

    if (OAuth.HttpMethod.POST.equals(requestMethod) || OAuth.HttpMethod.PUT.equals(requestMethod)) {
        httpURLConnection.setDoOutput(true);
        OutputStream ost = httpURLConnection.getOutputStream();
        PrintWriter pw = new PrintWriter(ost);
        pw.print(requestBody);
        pw.flush();
        pw.close();
    }
}
 
开发者ID:opensourceBIM,项目名称:BIMserver,代码行数:17,代码来源:URLConnectionClient.java

示例2: execute

import org.apache.oltu.oauth2.client.request.OAuthClientRequest; //导入方法依赖的package包/类
public <T extends OAuthClientResponse> T execute(OAuthClientRequest request, Map<String, String> headers,
        String requestMethod, Class<T> responseClass)
                throws OAuthSystemException, OAuthProblemException {

    MediaType mediaType = MediaType.parse("application/json");
    Request.Builder requestBuilder = new Request.Builder().url(request.getLocationUri());

    if(headers != null) {
        for (Entry<String, String> entry : headers.entrySet()) {
            if (entry.getKey().equalsIgnoreCase("Content-Type")) {
                mediaType = MediaType.parse(entry.getValue());
            } else {
                requestBuilder.addHeader(entry.getKey(), entry.getValue());
            }
        }
    }

    RequestBody body = request.getBody() != null ? RequestBody.create(mediaType, request.getBody()) : null;
    requestBuilder.method(requestMethod, body);

    try {
        Response response = client.newCall(requestBuilder.build()).execute();
        return OAuthClientResponseFactory.createCustomResponse(
                response.body().string(), 
                response.body().contentType().toString(),
                response.code(),
                responseClass);
    } catch (IOException e) {
        throw new OAuthSystemException(e);
    }
}
 
开发者ID:ARMmbed,项目名称:mbed-cloud-sdk-java,代码行数:32,代码来源:OAuthOkHttpClient.java

示例3: execute

import org.apache.oltu.oauth2.client.request.OAuthClientRequest; //导入方法依赖的package包/类
public <T extends OAuthClientResponse> T execute(OAuthClientRequest request, Map<String, String> headers,
            String requestMethod, Class<T> responseClass)
                    throws OAuthSystemException, OAuthProblemException {

        MediaType mediaType = MediaType.parse("application/json");
        Request.Builder requestBuilder = new Request.Builder().url(request.getLocationUri());

        if(headers != null) {
            for (Entry<String, String> entry : headers.entrySet()) {
                if (entry.getKey().equalsIgnoreCase("Content-Type")) {
                    mediaType = MediaType.parse(entry.getValue());
                } else {
                    requestBuilder.addHeader(entry.getKey(), entry.getValue());
                }
            }
        }

        RequestBody body = request.getBody() != null ? RequestBody.create(mediaType, request.getBody()) : null;
        requestBuilder.method(requestMethod, body);

//        try {
//            Response response = client.newCall(requestBuilder.build()).execute();
//            return OAuthClientResponseFactory.createCustomResponse(
//                    response.body().string(),
//                    response.body().contentType().toString(),
//                    response.code(),
//                    responseClass);
//        } catch (IOException e) {
//            throw new OAuthSystemException(e);
//        }
        return null; // FIXME: Oauth should be tested
    }
 
开发者ID:amardeshbd,项目名称:medium-api-android-sample,代码行数:33,代码来源:OAuthOkHttpClient.java

示例4: execute

import org.apache.oltu.oauth2.client.request.OAuthClientRequest; //导入方法依赖的package包/类
public <T extends OAuthClientResponse> T execute(OAuthClientRequest request, Map<String, String> headers,
        String requestMethod, Class<T> responseClass)
                throws OAuthSystemException, OAuthProblemException {

    MediaType mediaType = MediaType.parse("application/json");
    Builder requestBuilder = new Builder().url(request.getLocationUri());

    if(headers != null) {
        for (Entry<String, String> entry : headers.entrySet()) {
            if (entry.getKey().equalsIgnoreCase("Content-Type")) {
                mediaType = MediaType.parse(entry.getValue());
            } else {
                requestBuilder.addHeader(entry.getKey(), entry.getValue());
            }
        }
    }

    RequestBody body = request.getBody() != null ? RequestBody.create(mediaType, request.getBody()) : null;
    requestBuilder.method(requestMethod, body);

    try {
        Response response = client.newCall(requestBuilder.build()).execute();
        return OAuthClientResponseFactory.createCustomResponse(
                response.body().string(), 
                response.body().contentType().toString(),
                response.code(),
                responseClass);
    } catch (IOException e) {
        throw new OAuthSystemException(e);
    }
}
 
开发者ID:hardsky,项目名称:lucky-calories,代码行数:32,代码来源:OAuthOkHttpClient.java


注:本文中的org.apache.oltu.oauth2.client.request.OAuthClientRequest.getBody方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。