use of org.xdi.oxauth.model.net.HttpServiceResponse in project oxAuth by GluuFederation.
the class HttpService method executePost.
public HttpServiceResponse executePost(HttpClient httpClient, String uri, String authData, Map<String, String> headers, String postData, ContentType contentType) {
HttpPost httpPost = new HttpPost(uri);
if (StringHelper.isNotEmpty(authData)) {
httpPost.setHeader("Authorization", "Basic " + authData);
}
if (headers != null) {
for (Entry<String, String> headerEntry : headers.entrySet()) {
httpPost.setHeader(headerEntry.getKey(), headerEntry.getValue());
}
}
StringEntity stringEntity = new StringEntity(postData, contentType);
httpPost.setEntity(stringEntity);
try {
HttpResponse httpResponse = httpClient.execute(httpPost);
return new HttpServiceResponse(httpPost, httpResponse);
} catch (IOException ex) {
log.error("Failed to execute post request", ex);
}
return null;
}
Aggregations