Return-Path: X-Original-To: apmail-hc-httpclient-users-archive@www.apache.org Delivered-To: apmail-hc-httpclient-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8E74A99B3 for ; Fri, 24 Feb 2012 16:32:08 +0000 (UTC) Received: (qmail 57119 invoked by uid 500); 24 Feb 2012 16:32:08 -0000 Delivered-To: apmail-hc-httpclient-users-archive@hc.apache.org Received: (qmail 57059 invoked by uid 500); 24 Feb 2012 16:32:08 -0000 Mailing-List: contact httpclient-users-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpClient User Discussion" Delivered-To: mailing list httpclient-users@hc.apache.org Received: (qmail 57048 invoked by uid 99); 24 Feb 2012 16:32:08 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 24 Feb 2012 16:32:08 +0000 X-ASF-Spam-Status: No, hits=0.9 required=5.0 tests=HK_RANDOM_ENVFROM,HK_RANDOM_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of lbrtchx@gmail.com designates 209.85.214.179 as permitted sender) Received: from [209.85.214.179] (HELO mail-tul01m020-f179.google.com) (209.85.214.179) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 24 Feb 2012 16:32:04 +0000 Received: by obbup6 with SMTP id up6so2953952obb.10 for ; Fri, 24 Feb 2012 08:31:43 -0800 (PST) Received-SPF: pass (google.com: domain of lbrtchx@gmail.com designates 10.182.72.69 as permitted sender) client-ip=10.182.72.69; Authentication-Results: mr.google.com; spf=pass (google.com: domain of lbrtchx@gmail.com designates 10.182.72.69 as permitted sender) smtp.mail=lbrtchx@gmail.com; dkim=pass header.i=lbrtchx@gmail.com Received: from mr.google.com ([10.182.72.69]) by 10.182.72.69 with SMTP id b5mr1046155obv.77.1330101103886 (num_hops = 1); Fri, 24 Feb 2012 08:31:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; bh=KMAGil31MmcGyKMS7r67pDA6gnyDOFt/cMr6ZrGrTUM=; b=JKNAecUTrVQvxwwnAY8Lfx+ZU2AyQGVGYxrcUkmiRfcCdMlXKc/uM40kQg6FYeWbN8 H6xmjBHHmmVTiqceVwjjCZimF2WF6XPM6YZEtfJ4+EgrS9WQsk2rF6YSUDl4GNiruXLR O249xWArKgurjUiwnsWfnle2B/Vlqn0UV+21I= MIME-Version: 1.0 Received: by 10.182.72.69 with SMTP id b5mr922558obv.77.1330101103824; Fri, 24 Feb 2012 08:31:43 -0800 (PST) Received: by 10.182.25.234 with HTTP; Fri, 24 Feb 2012 08:31:43 -0800 (PST) Date: Fri, 24 Feb 2012 16:31:43 +0000 Message-ID: Subject: getting Fully Qualified Domain Name (FQDN) ... From: Albretch Mueller To: httpclient-users@hc.apache.org Content-Type: text/plain; charset=ISO-8859-1 ~ Say you want to keep the local copies of documents you download/view online in a directory structure that somewhat resembles the URL path. ~ Firefox seems to darken the FQDN, but then you can check it doesn't do it truthfully. Try for example: ~ http://www-hiel.ist.osaka-u.ac.jp/~iizuka/Hiroyuki_Iizuka.html http://www.c.u-tokyo.ac.jp/eng_site/ ~ Why is it that u-tokyo.ac.jp throws an UnknownHostException? ~ As I see it, neither the java API nor HTTP Client offer an utility that would let you know for example that "nces.ed.gov" is not a FQDN, but "ed.gov", so that you can build local directory structures that better resemble the URLs ~ In the case of cognition.iig.uni-freiburg.de, the FQDN is "uni-freiburg.de" and there are indeed separate hosts at "cognition.iig.uni-freiburg.de" and "iig.uni-freiburg.de", so that "iig" would be a directory inside of "cognition", but in the case of "www-hiel.ist.osaka-u.ac.jp" the host seems to be "www-hiel.ist.osaka-u.ac.jp" ... ~ lbrtchx ~ Here is the demo/toy code I used: import java.net.*; import java.util.*; // __ public class GetCanonicalHostName{ public static void main(String[] args){ String[][] aHNms = new String[][]{ {"sussex.ac.uk", "ac.uk"}, {"www.mathstat.dal.ca", "mathstat.dal.ca", "dal.ca"}, {"www-hiel.ist.osaka-u.ac.jp", "ist.osaka-u.ac.jp", "osaka-u.ac.jp", "ac.jp"}, {"www.c.u-tokyo.ac.jp", "c.u-tokyo.ac.jp", "u-tokyo.ac.jp"}, {"hardware.slashdot.org", "slashdot.org"}, {"cognition.iig.uni-freiburg.de", "iig.uni-freiburg.de", "uni-freiburg.de"}, {"www.york.ac.uk", "york.ac.uk", "ac.uk"}, {"newyorkweb.york.ac.uk", "york.ac.uk", "ac.uk"}, {"pas.fdle.state.fl.us", "fdle.state.fl.us", "state.fl.us", "fl.us"}, {"nces.ed.gov", "ed.gov"}, }; // __ InetAddress ia = null; for(int i = 0; (i < aHNms.length); ++i){ System.out.println("// __ " + aHNms[i].length + ":"); for(int j = 0; (j < aHNms[i].length); ++j){ System.out.print("// __ " + aHNms[i][j] + " | "); try{ ia = InetAddress.getByName(aHNms[i][j]); System.out.println(ia.getCanonicalHostName() + " | " + ia.getHostAddress()); }catch(UnknownHostException UnkHX){ UnkHX.printStackTrace(); } } System.out.println("~"); } } } --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org For additional commands, e-mail: httpclient-users-help@hc.apache.org