You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by Rob Tice <ro...@k-int.com> on 2003/04/10 10:57:26 UTC

timeout question


A quick repost as I didn't get any responses last time.

I am occasionally getting a timeout exception during connect or read
using httpclient. The problem is that I have set the timeouts to 60
seconds and these timeouts are occurring after between 2 and 3 seconds
(using 2.0 alpha 3 - timings from my log file). Any guesses as to what
is happening and why the timeout exception doesn't take 60 seconds to be
thrown.

Apologies if it is simply my lack of httpclient knowledge :)


Rob Tice
rob.tice@k-int.com



Re: Parsing "Last-Modified" HTTP response header

Posted by Chris Brown <br...@reflexe.fr>.
Well, I'm an impatient chap... didn't find the code, so I coded it myself.

Here as a reference for anyone else (maybe worth including in the API, once
it's been verified).  Careful with line breaks...
____________________________________________________________

 /**
  * Date format pattern used to parse HTTP date headers in RFC 1123 format.
  * <p>Dates may be formatted using the following patterns (listed in order
  * of preference):</p>
  * <ol>
  * <li><code>RFC 1123 format</code> (recommended)</li>
  * <li>{@link #PATTERN_RFC1036 RFC 1036 format) (deprecated)</li>
  * <li>{@link #PATTERN_ASCTIME ANSI C asctime() format} (deprecated)</li>
  * </ol>
  */
 public static final String PATTERN_RFC1123 =
 "EEE, dd MMM yyyy HH:mm:ss zzz";

 /**
  * Date format pattern used to parse HTTP date headers in RFC 1036 format.
  * <p>Dates may be formatted using the following patterns (listed in order
  * of preference):</p>
  * <ol>
  * <li>{@link #PATTERN_RFC1123 RFC 1123 format} (recommended)</li>
  * <li><code>RFC 1036 format</code> (deprecated)</li>
  * <li>{@link #PATTERN_ASCTIME ANSI C asctime() format} (deprecated)</li>
  * </ol>
  */
 public static final String PATTERN_RFC1036 =
 "EEEE, dd-MMM-yy HH:mm:ss zzz";

 /**
  * Date format pattern used to parse HTTP date headers in ANSI C
<code>asctime()</code> format.
  * <p>Dates may be formatted using the following patterns (listed in order
  * of preference):</p>
  * <ol>
  * <li>{@link #PATTERN_RFC1123 RFC 1123 format} (recommended)</li>
  * <li>{@link #PATTERN_RFC1036 RFC 1036 format) (deprecated)</li>
  * <li><code>ANSI C asctime() format</code> (deprecated)</li>
  * </ol>
  */
 public static final String PATTERN_ASCTIME =
 "EEE MMM d HH:mm:ss yyyy";

 /**
  * Parses a HTTP header date value.
  *
  * @param dateHeaderValue the date header value to parse.
  * @return the parsed date.
  *
  * @throws ParseException if the date could not be parsed according to the
  *  one of the following formats (in order of preference):
  *  {@link #PATTERN_RFC1123 RFC 1123},
  *  {@link #PATTERN_RFC1036 RFC 1036},
  *  {@link #PATTERN_ASCTIME ANSI C asctime() format}.
  *
  *  @author Christopher Brown
  */
 public static Date parseDateHeader(String dateHeaderValue) throws
ParseException
 {
  Date date = null;
  if (dateHeaderValue != null)
  {
   SimpleDateFormat dateParser = new SimpleDateFormat(PATTERN_RFC1123,
Locale.US);
   dateParser.setTimeZone(TimeZone.getTimeZone("GMT"));
   try
   {
    date = dateParser.parse(dateHeaderValue);
   }
   catch (ParseException exRFC1123)
   {
    dateParser.applyPattern(PATTERN_RFC1036);
    try
    {
     date = dateParser.parse(dateHeaderValue);
    }
    catch (ParseException exRFC1036)
    {
     dateParser.applyPattern(PATTERN_ASCTIME);
     date = dateParser.parse(dateHeaderValue);
    }
   }
  }
  return date;
 }





Parsing "Last-Modified" HTTP response header

Posted by Chris Brown <br...@reflexe.fr>.
Hello,

Is there any built-in way in the Http Client API to obtain the value of the
"Last-Modified" header as a number of milliseconds or a Date (already
parsed), just like java.net.URLConnection.getLastModified() ?

Surely there's a method, or someone's already done that... Or do I have to
figure it out myself?! ;-)

Thanks,
Chris



Re: Unmentioned dependencies

Posted by Adrian Sutton <ad...@intencha.com>.
Hi Chris,
I'll provide a patch for the authentication docs tonight unless someone 
else beats me to it.

Thanks for pointing it out.

Regards,

Adrian Sutton.

On Friday, April 11, 2003, at 01:34  AM, Chris Brown wrote:

>
> I didn't see any mention on the HttpClient website or in any other docs
> about dependencies in HttpClient upon JCE (Java Cryptography 
> Extensions) for
> using NTLM.
>
> I discovered (via a NoClassDefFound error) that the following classes 
> are
> required if you use NTCredentials :
>
> javax.crypto.BadPaddingException;
> javax.crypto.Cipher;
> javax.crypto.IllegalBlockSizeException;
> javax.crypto.NoSuchPaddingException;
> javax.crypto.spec.SecretKeySpec;
>
> Could you mention in the docs / on the site that JCE or JDK 1.4 
> (including
> JCE) is required for NTLM authentification (so that others don't get 
> stuck)?
>
> Thanks,
> Chris
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: 
> commons-httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: 
> commons-httpclient-dev-help@jakarta.apache.org
>


Unmentioned dependencies

Posted by Chris Brown <br...@reflexe.fr>.
I didn't see any mention on the HttpClient website or in any other docs
about dependencies in HttpClient upon JCE (Java Cryptography Extensions) for
using NTLM.

I discovered (via a NoClassDefFound error) that the following classes are
required if you use NTCredentials :

javax.crypto.BadPaddingException;
javax.crypto.Cipher;
javax.crypto.IllegalBlockSizeException;
javax.crypto.NoSuchPaddingException;
javax.crypto.spec.SecretKeySpec;

Could you mention in the docs / on the site that JCE or JDK 1.4 (including
JCE) is required for NTLM authentification (so that others don't get stuck)?

Thanks,
Chris



Re: timeout question

Posted by Michael Becke <be...@u.washington.edu>.
Hi Rob,

Sorry for the delay.  Could you send an example of the code you are 
using and that is failing.  Also, a log of this problem would help.  
Please take a look at:

http://jakarta.apache.org/commons/httpclient/logging.html

Mike

On Thursday, April 10, 2003, at 04:57 AM, Rob Tice wrote:

>
>
> A quick repost as I didn't get any responses last time.
>
> I am occasionally getting a timeout exception during connect or read
> using httpclient. The problem is that I have set the timeouts to 60
> seconds and these timeouts are occurring after between 2 and 3 seconds
> (using 2.0 alpha 3 - timings from my log file). Any guesses as to what
> is happening and why the timeout exception doesn't take 60 seconds to 
> be
> thrown.
>
> Apologies if it is simply my lack of httpclient knowledge :)
>
>
> Rob Tice
> rob.tice@k-int.com
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: 
> commons-httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: 
> commons-httpclient-dev-help@jakarta.apache.org
>