本文整理汇总了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();
}
}
示例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);
}
}
示例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
}
示例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);
}
}