hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: invalid redirect
Date Tue, 04 Jul 2006 16:49:28 GMT
On Tue, 2006-07-04 at 18:46 +0300, Eugene Dzhurinsky wrote:
> 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
> 

What is so strange about it? The second redirect location contains
garbage.

Oleg

[DEBUG] header - >>
"GET /cgi-bin/ads.pl?member=atwork_side3;page=781;setdest=atwork_side3
HTTP/1.1[\r][\n]"
[DEBUG] header - >> "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0;
Windows NT 5.0)[\r][\n]"
[DEBUG] header - >> "Host: www.emigrant.ie[\r][\n]"
[DEBUG] header - >> "[\r][\n]"
[DEBUG] header - << "HTTP/1.1 302 Object Moved[\r][\n]"
[DEBUG] header - << "Location:
http://www.emigrant.ie/cgi-bin/ads.pl?member=atwork_side3;page=781;setdest=atwork_side3;checkforcookie[\r][\n]"
[DEBUG] header - << "Server: Microsoft-IIS/5.0[\r][\n]"
[DEBUG] header - << "Content-Type: text/html[\r][\n]"
[DEBUG] header - << "Connection: close[\r][\n]"
[DEBUG] header - << "Content-Length: 225[\r][\n]"
[DEBUG] header - >>
"GET /cgi-bin/ads.pl?member=atwork_side3;page=781;setdest=atwork_side3;checkforcookie HTTP/1.1[\r][\n]"
[DEBUG] header - >> "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0;
Windows NT 5.0)[\r][\n]"
[DEBUG] header - >> "Host: www.emigrant.ie[\r][\n]"
[DEBUG] header - >> "[\r][\n]"
[DEBUG] header - << "HTTP/1.1 302 Object Moved[\r][\n]"
[DEBUG] header - << "Location:
http://www.arguscarhire.com/Newimages/BANNERS/argus_car_hire_130x60_from[0xef][0xbf][0xbd]9.99.gif[\r][\n]"
[DEBUG] header - << "Server: Microsoft-IIS/5.0[\r][\n]"
[DEBUG] header - << "Content-Type: text/html[\r][\n]"
[DEBUG] header - << "Connection: close[\r][\n]"
[DEBUG] header - << "Content-Length: 204[\r][\n]"



> 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);
>         }
>     }
> 
> }


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


Mime
View raw message