hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: java.net.URL or URI
Date Sat, 11 Mar 2006 16:24:52 GMT
On Sat, 2006-03-11 at 10:39 -0500, John Buren Southerland wrote:
> Fair enough ;)
> I know it is silly, I just kept wondering why the URL class was not
> supported directly, the 1.2 support answers everything.
> 
> Do any dreams/plans exist to add a "user" timeout that isn't tied to
> socket or connection timeout?

John,

While not entirely impossible to implement using classic IO model, the
support for a 'user' timeout would require a lot of _really_ ugly code.
It is by far better to implement a controller thread that aborts the
execution of methods if a certain condition is met. 

The story is completely different for the NIO (non-blocking IO, that
is). It should be fairly uncomplicated to keep track of total tome spent
executing an operation when a channel selector is being employed. We
might consider adding the total timeout for HttpComponents HttpNIO
module

Oleg

> I have a sigalarm like thingy that requires 1.5, but obviously that
> won't work for a library like this.  
> Thanks again, John
> 
> PS: Don't worry about me, I am way to emotionally invested in log4j to
> nest statements so deep like the example I typed out for reference.  I
> would have like six potential problems in each line of code.
> 
> On Sat, 2006-03-11 at 10:20 +0100, Roland Weber wrote:
> 
> > Hi John,
> > 
> > > Pattern pat = new Pattern(someReallyCoolRegexHere);
> > > Matcher match = pat.matcher(webPageTextHere);
> > > while( match.find() )
> > >     GetMethod get = new GetMethod( new URL( topURL,
> > > match.group(1)).toString() );
> > > 
> > > but if the url was supported, and extended with some of the simple
> > > features, it would be cleaner:
> > > 
> > > GetMethod get = new GetMethod( topUrl, match.group(1) );
> > > 
> > > As I type this I realize it is probably trivial, but surely a reason
> > > must exist that string was supported rather than url?
> > 
> > The URL class has 6 constructors in JDK 1.4.2 (I didn't bother to
> > check which ones were in the eralier JDK version which is the
> > prerequisite for HttpClient). Surely you don't expect us to duplicate
> > all of them just to save you a single line of code and two braces?
> > 
> > while( match.find() ) {
> >   URL from = new URL( topURL, match.group(1) );
> >   GetMethod get = new GetMethod( from.toString() );
> >   ... // I assume that something was omitted here, otherwise
> >       // you are pointlessly creating objects in a loop :-)
> > }
> > 
> > If you choose to make your code unreadable by nesting statements,
> > it is only fair that *you* should suffer the consequences.
> > 
> > The URI class was introduced with JDK 1.4. HttpClient requires only
> > an older JDK, I don't have in mind whether that was 1.2 or 1.3. But
> > the URI class also has a toString() method that can easily be used
> > in the way shown above. See how flexible the string constructor is?
> > 
> > cheers,
> >   Roland
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org
> > 
> 
> John Buren Southerland
> Principal Consultant
> Southerland Consulting, Inc.
> Office: 801.467.8090
> Cell: 214.734.8099
> Email: john@southerland-consulting.com


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org


Mime
View raw message