On Mon, 2002-05-06 at 17:43, Donald Ball wrote:

> anyway, attached is a short usage sample document for HttpClient. i'll
> see about fleshing it out if anyone has any comments.

er, okay, looks like jakarta's mail server silently drops attachments.
here it is inline.

- donald

<?xml version="1.0"?>
<document>
  <properties>
    <title>Usage</title>
    <author email="[EMAIL PROTECTED]">Commons Documentation Team</author>
    <author email="[EMAIL PROTECTED]">Donald Ball</author>
    <revision>$Id$</revision>
  </properties>
  <body>
    <section name="Usage">
      <p>Here is a short example program to help you get up to speed with HttpClient. 
It checks to see if a resource exists using the <code>HEAD</code> method.</p>
      <source><![CDATA[
public boolean testURL(String url) {

    HttpMultiClient client = new HttpMultiClient();
    HttpUrlMethod method = null;
    int status = -1;

    try {
        method = new UrlHeadMethod(url);
    } catch (MalformedURLException e) {
        throw new RuntimeException("Could not test malformed URL: "+
                                   url + ": " + e.getMessage());
    }
    method.setFollowRedirects(true);
    status = client.executeMethod(method);
    return (status == HttpStatus.SC_OK);

}
]]></source>
      <p>If you have many requests to make, you will probably want to reuse these 
objects. <code>HttpMultiClient</code>'s executeMethod method is threadsafe, while the 
<code>HttpUrlMethod</code> objects can be recycled after they're used.</p>
    </section>
  </body>
</document>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to