tempNode.putByteArray("xxx", url.getUserInfo().getBytes());
String authInfo = tempNode.get("xxx", null);
tempNode.removeNode();
//
sslContext.init(null, new TrustManager[] { new TrustEveryone() }, null);
HttpsURLConnection urlConnection = (HttpsURLConnection) url.openConnection();
// HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setRequestProperty("User-Agent", "jhg/0.1.0");
urlConnection.setRequestProperty("Accept", "application/mercurial-0.1");
urlConnection.setRequestProperty("Authorization", "Basic " + authInfo);
urlConnection.setSSLSocketFactory(sslContext.getSocketFactory());
// byte[] body = "pairs=f5aed108754e817d2ca374d1a4f6daf1218dcc91-9429c7bd1920fab164a9d2b621d38d57bcb49ae0".getBytes();
// urlConnection.setRequestMethod("POST");
// urlConnection.setRequestProperty("Content-Length", String.valueOf(body.length));
// urlConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
// urlConnection.setDoOutput(true);
// urlConnection.setDoInput(true);
urlConnection.connect();
// OutputStream os = urlConnection.getOutputStream();
// os.write(body);
// os.flush();
// os.close();
System.out.println("Query:" + url.getQuery());
System.out.println("Response headers:");
final Map<String, List<String>> headerFields = urlConnection.getHeaderFields();
for (String s : headerFields.keySet()) {
System.out.printf("%s: %s\n", s, urlConnection.getHeaderField(s));
}
System.out.printf("Content type is %s and its length is %d\n", urlConnection.getContentType(), urlConnection.getContentLength());
InputStream is = urlConnection.getInputStream();
//
// dump(is, -1); // simple dump, any cmd
writeBundle(is, false, "HG10GZ"); // cmd=changegroup
//writeBundle(is, true, "" or "HG10UN");
//
urlConnection.disconnect();
//
}