{
getConnection ().connect ();
}
catch (UnknownHostException uhe)
{
throw new ParserException ("Connect to "
+ mConnection.getURL ().toExternalForm () + " failed.", uhe);
}
catch (IOException ioe)
{
throw new ParserException ("Exception connecting to "
+ mConnection.getURL ().toExternalForm ()
+ " (" + ioe.getMessage () + ").", ioe);
}
type = getContentType ();
charset = getCharset (type);
try
{
contentEncoding = connection.getContentEncoding();
if ((null != contentEncoding)
&& (-1 != contentEncoding.indexOf ("gzip")))
{
stream = new Stream (new GZIPInputStream (
getConnection ().getInputStream ()));
}
else if ((null != contentEncoding)
&& (-1 != contentEncoding.indexOf ("deflate")))
{
stream = new Stream (new InflaterInputStream (
getConnection ().getInputStream (), new Inflater (true)));
}
else
{
stream = new Stream (getConnection ().getInputStream ());
}
try
{
mSource = new InputStreamSource (stream, charset);
}
catch (UnsupportedEncodingException uee)
{
// StringBuffer msg;
//
// msg = new StringBuffer (1024);
// msg.append (getConnection ().getURL ().toExternalForm ());
// msg.append (" has an encoding (");
// msg.append (charset);
// msg.append (") which is not supported, using ");
// msg.append (DEFAULT_CHARSET);
// System.out.println (msg.toString ());
charset = DEFAULT_CHARSET;
mSource = new InputStreamSource (stream, charset);
}
}
catch (IOException ioe)
{
throw new ParserException ("Exception getting input stream from "
+ mConnection.getURL ().toExternalForm ()
+ " (" + ioe.getMessage () + ").", ioe);
}
mUrl = connection.getURL ().toExternalForm ();
mIndex = new PageIndex (this);