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(); } }
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(); } }
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(); } }
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(); } }
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); } }
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); } }
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); } }
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); } }
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); } }
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); } }
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(), response.headers().toMultimap(), responseClass); } catch (IOException e) { throw new OAuthSystemException(e); } }
HttpEntity entity = new StringEntity(request.getBody()); ((HttpPost)req).setEntity(entity); } else {
HttpEntity entity = new StringEntity(request.getBody()); ((HttpPost)req).setEntity(entity); } else {
String contentType = headers.get("Content-Type"); String url = request.getLocationUri(); String body = request.getBody(); Builder builder = this.client.resource(url).getRequestBuilder();