Hello, I facing strange issue with HttpClient

For this URL: 
http://www.emigrant.ie/cgi-bin/ads.pl?member=atwork_side3;page=781;setdest=atwork_side3

it reports 302 instead of 200, and

WARNING: Redirected location
'http://www.arguscarhire.com/Newimages/BANNERS/argus_car_hire_130x60_from?9.99.gif'
is malformed

You may find unit test below

import junit.framework.Assert;
import junit.framework.TestCase;
import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.cookie.CookiePolicy;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.params.HttpClientParams;
import org.apache.commons.httpclient.params.HttpMethodParams;

import java.io.IOException;

public class HTTPClientTest extends TestCase {

    HttpClient client;

    HttpMethod method;

    public static void main(String[] args) {
        TestCase test = new HTTPClientTest() {
            public void runTest() {
                testResultcode();
            };
        };
    }

    protected void setUp() throws Exception {
        client = new HttpClient();
        String url = 
"http://www.emigrant.ie/cgi-bin/ads.pl?member=atwork_side3;page=781;setdest=atwork_side3";;
        URI uri = new URI(url, url.indexOf('%') != -1);
        method = new GetMethod();
        method.setURI(uri);
        method.setRequestHeader("HTTP_REFERER",
                "http://www.emigrant.ie/category.asp?iCategoryID=510";);
        HttpMethodParams params = method.getParams();
        params.setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
        params.setParameter(HttpClientParams.USER_AGENT, "Mozilla/4.0"
                + "(compatible; MSIE 6.0; Windows NT 5.1;)");
        method.setFollowRedirects(true);
    }

    public void testResultcode() {
        try {
            client.executeMethod(method);
            Assert.assertEquals(HttpStatus.SC_OK, method.getStatusCode());
        } catch (HttpException e) {
            e.printStackTrace(System.out);
        } catch (IOException e) {
            e.printStackTrace(System.out);
        }
    }

}
-- 
Eugene N Dzhurinsky

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

Reply via email to