Example usage for javax.net.ssl HttpsURLConnection getContent

List of usage examples for javax.net.ssl HttpsURLConnection getContent

Introduction

In this page you can find the example usage for javax.net.ssl HttpsURLConnection getContent.

Prototype

public Object getContent() throws IOException 

Source Link

Document

Retrieves the contents of this URL connection.

Usage

From source file:com.beanstream.connection.HttpsConnector.java

/**
 * Provide a detailed error message when connecting to the Beanstream API fails.
 *///from   w w w .  j a v a  2 s . c  o  m
private BeanstreamApiException handleException(Exception ex, HttpsURLConnection connection) {
    String message = "";
    if (connection != null) {
        try {
            int responseCode = connection.getResponseCode();
            message = responseCode + " " + connection.getContent().toString();
        } catch (IOException ex1) {
            Logger.getLogger(HttpsConnector.class.getName()).log(Level.SEVERE, "Error getting response code",
                    ex1);
        }
    } else {
        message = "Connection error";
    }
    return new BeanstreamApiException(ex, message);
}

From source file:net.roboconf.target.azure.internal.AzureIaasHandler.java

private String processGetRequest(URL url, String keyStore, String keyStorePassword)
        throws GeneralSecurityException, IOException {

    SSLSocketFactory sslFactory = this.getSSLSocketFactory(keyStore, keyStorePassword);
    HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
    con.setSSLSocketFactory(sslFactory);
    con.setRequestMethod("GET");
    con.addRequestProperty("x-ms-version", "2014-04-01");
    InputStream responseStream = (InputStream) con.getContent();

    ByteArrayOutputStream os = new ByteArrayOutputStream();
    Utils.copyStreamSafely(responseStream, os);
    return os.toString("UTF-8");
}

From source file:com.appdynamics.monitors.azure.statsCollector.AzureServiceBusStatsCollector.java

private InputStream processGetRequest(URL url, String keyStore, String keyStorePassword) {
    SSLSocketFactory sslFactory = getSSLSocketFactory(keyStore, keyStorePassword);
    HttpsURLConnection con = null;
    try {//from  w w  w . j  av a  2 s.  c o  m
        con = (HttpsURLConnection) url.openConnection();
    } catch (IOException e) {
        logger.error(e.getMessage(), e);
        throw new RuntimeException(e.getMessage(), e);
    }
    con.setSSLSocketFactory(sslFactory);
    try {
        con.setRequestMethod(REQUEST_METHOD_GET);
    } catch (ProtocolException e) {
        logger.error(e.getMessage(), e);
        throw new RuntimeException(e.getMessage(), e);
    }

    con.addRequestProperty(X_MS_VERSION_HEADER, X_MS_VERSION);

    InputStream responseStream = null;
    try {
        responseStream = (InputStream) con.getContent();
    } catch (IOException e) {
        logger.error(e.getMessage(), e);
        throw new RuntimeException(e.getMessage(), e);
    }

    return responseStream;
}