/* * [TestConnection.java] * * Summary: Does an HTTP connect without reading anything. For experimenting with failed connections. * * Copyright: (c) 2016-2017 Roedy Green, Canadian Mind Products, http://mindprod.com * * Licence: This software may be copied and used freely for any purpose but military. * http://mindprod.com/contact/nonmil.html * * Requires: JDK 1.8+ * * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/ * * Version History: * 1.0 2016-07-10 initial version */ package com.mindprod.example; import java.net.HttpURLConnection; import java.net.URL; import static java.lang.System.*; /** * Does an HTTP connect without reading anything. For experimenting with failed connections. *

* Based on code by Arne Vajhøj arne@vajhoej.dk * * @author Roedy Green, Canadian Mind Products * @version 1.0 2016-07-10 initial version * @since 2016-07-10 */ public class TestConnection { public static void main( String[] args ) { final String urlString = args[ 0 ]; probe( urlString ); } public static void probe( String urlstr ) { try { System.setProperty( "java.net.preferIPv4Stack", "true" ); // If you set this false, and your site supports SNI, you will not be able to connect. // You have to try it both ways or keep track on a site by site basis System.setProperty( "jsse.enableSNIExtension", "false" ); System.setProperty( "jdk.tls.ephemeralDHKeySize", "2048" ); out.println( urlstr ); final URL url = new URL( urlstr ); final HttpURLConnection con = ( HttpURLConnection ) url.openConnection(); out.println( con.getHeaderFields() ); con.connect(); out.println( "\nreceived: ResponseCode: " + con.getResponseCode() + " ContentLength: " + con.getContentLength() + " ContentEncoding: " + con.getContentEncoding() ); con.disconnect(); } catch ( Exception e ) { e.printStackTrace(); } } /* test urls http://www.vajhoej.dk/ https://www.ashampoo.com/en/cad/pin/7110/burning-software/burning-studio-free https://cdburnerxp.se/en/home https://handbrake.fr https://www.htmlvalidator.com/download/registered.php?versionin=110 https://support.logitech.com/en_us/Product/wireless-mouse-m510#download https://www.meinbergglobal.com/english/sw/ntp.htm https://inkscape.org/en/ https://outernet.is/lighthouse https://sliksvn.com/download/ https://tortoisesvn.net */ }