Java Code Examples for com.intellij.util.net.HttpConfigurable#prepareURL()

The following examples show how to use com.intellij.util.net.HttpConfigurable#prepareURL() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PluginErrorReportSubmitter.java    From BashSupport with Apache License 2.0 6 votes vote down vote up
private boolean tryConnectOnly(String serverUrl) {
    boolean tryAgain = false;
    do {
        try {
            HttpConfigurable httpConfigurable = HttpConfigurable.getInstance();
            httpConfigurable.prepareURL(serverUrl);
        } catch (IOException ioe) {
            LOGGER.info("Connection error", ioe);
            tryAgain = IOExceptionDialog.showErrorDialog("Error",
                    String.format("Unable to connect to \"%s\". Make sure your proxy settings are correct.", serverUrl)
            );

            // abort if cannot connect to server and user does not want to try again
            if (!tryAgain) {
                return false;
            }
        }
    } while (tryAgain);

    return true;
}
 
Example 2
Source File: PluginErrorReportSubmitter.java    From BashSupport with Apache License 2.0 6 votes vote down vote up
@Nullable
private String readUrlContentWithProxy(String urlString) {
    // first, check if connection to server can be established, i.e. proxy settings are correct
    boolean tryAgain = false;
    do {
        try {
            HttpConfigurable httpConfigurable = HttpConfigurable.getInstance();
            httpConfigurable.prepareURL(urlString);
        } catch (IOException ioe) {
            LOGGER.info("Connection error", ioe);
            tryAgain = IOExceptionDialog.showErrorDialog("Error", String.format("Unable to connect to \"%s\". Make sure your proxy settings are correct.", urlString));

            // abort if cannot connect to server and user does not want to try again
            if (!tryAgain) {
                return null;
            }
        }
    } while (tryAgain);

    // second, connect to server and read content
    return readUrlContent(urlString);
}