You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Phani Sajja <sa...@gmail.com> on 2010/04/23 11:32:20 UTC

Handling Redirects automatically in HttpClient4.0.1

Hi all,
        I am using HttpClient version 4.0.1. When I execute a method on a
link I am getting error 302 saying HTTP/1.0 302 Moved Temporarily. How to
handle redirects automatically so that I can get the final page. Help me
please!

-- 
Regards
Phani. S

Re: Handling Redirects automatically in HttpClient4.0.1

Posted by Phani Sajja <sa...@gmail.com>.
Oleg,
     Even if I set HANDLE_REDIRECTS to true or remove the line "
httpclient.getParams().setParameter(ClientPNames.HANDLE_REDIRECTS, true);"
it is not working. Can you please try to run the sample code.

On Sat, Apr 24, 2010 at 3:32 PM, Oleg Kalnichevski <ol...@apache.org> wrote:

> On /24/42010 11:12, Phani Sajja wrote:
>
>> Oleg,
>>       It is true I am not getting the result. Getting 302 error. This is
>> not
>> the home page which I am accessing (check searchURI) . Try to run the code
>> and tell me what have u got.
>>
>>
>>
> You TURNED OFF redirect handling in YOUR code and now are asking me why
> HttpClient is not handling redirects automatically!? Hello!?
>
> Oleg
>
>
>  On Sat, Apr 24, 2010 at 2:24 PM, Oleg Kalnichevski<ol...@apache.org>
>>  wrote:
>>
>>
>>
>>> On Sat, 2010-04-24 at 11:49 +0530, Phani Sajja wrote:
>>>
>>>
>>>> Hi Oleg,
>>>>          Here is the sample code which I am trying to get the search
>>>>
>>>>
>>> results
>>>
>>>
>>>>     String host = "www.tkdl.res.in";
>>>>     String searchURI = "/tkdl/langdefault/common/TKDLSearch.asp?GL=Eng";
>>>>         DefaultHttpClient httpclient = new DefaultHttpClient();
>>>>
>>>>         httpclient.getCredentialsProvider().setCredentials(
>>>>                 new AuthScope("172.31.100.14", 3128),
>>>>                 new UsernamePasswordCredentials("user", "pass"));
>>>>
>>>>         HttpHost targetHost = new HttpHost(host);
>>>>         HttpHost proxy = new HttpHost("172.31.100.14", 3128);
>>>>
>>>>
>>>>
>>>>
>>> httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY,
>>>
>>>
>>>> proxy);
>>>>
>>>>
>>>>
>>> httpclient.getParams().setParameter(ClientPNames.HANDLE_REDIRECTS,
>>>
>>>
>>>> false);
>>>>
>>>>
>>>>
>>> Ehhh? You are kidding, right?
>>>
>>> Oleg
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>>> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>>>
>>>
>>>
>>>
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>


-- 
Regards
Phani. S

Re: Handling Redirects automatically in HttpClient4.0.1

Posted by Oleg Kalnichevski <ol...@apache.org>.
On /24/42010 11:12, Phani Sajja wrote:
> Oleg,
>        It is true I am not getting the result. Getting 302 error. This is not
> the home page which I am accessing (check searchURI) . Try to run the code
> and tell me what have u got.
>
>    
You TURNED OFF redirect handling in YOUR code and now are asking me why 
HttpClient is not handling redirects automatically!? Hello!?

Oleg

> On Sat, Apr 24, 2010 at 2:24 PM, Oleg Kalnichevski<ol...@apache.org>  wrote:
>
>    
>> On Sat, 2010-04-24 at 11:49 +0530, Phani Sajja wrote:
>>      
>>> Hi Oleg,
>>>           Here is the sample code which I am trying to get the search
>>>        
>> results
>>      
>>>      String host = "www.tkdl.res.in";
>>>      String searchURI = "/tkdl/langdefault/common/TKDLSearch.asp?GL=Eng";
>>>          DefaultHttpClient httpclient = new DefaultHttpClient();
>>>
>>>          httpclient.getCredentialsProvider().setCredentials(
>>>                  new AuthScope("172.31.100.14", 3128),
>>>                  new UsernamePasswordCredentials("user", "pass"));
>>>
>>>          HttpHost targetHost = new HttpHost(host);
>>>          HttpHost proxy = new HttpHost("172.31.100.14", 3128);
>>>
>>>
>>>        
>> httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY,
>>      
>>> proxy);
>>>
>>>        
>> httpclient.getParams().setParameter(ClientPNames.HANDLE_REDIRECTS,
>>      
>>> false);
>>>
>>>        
>> Ehhh? You are kidding, right?
>>
>> Oleg
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>>
>>
>>      
>
>    


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


Re: Handling Redirects automatically in HttpClient4.0.1

Posted by Phani Sajja <sa...@gmail.com>.
Oleg,
      It is true I am not getting the result. Getting 302 error. This is not
the home page which I am accessing (check searchURI) . Try to run the code
and tell me what have u got.

On Sat, Apr 24, 2010 at 2:24 PM, Oleg Kalnichevski <ol...@apache.org> wrote:

> On Sat, 2010-04-24 at 11:49 +0530, Phani Sajja wrote:
> > Hi Oleg,
> >          Here is the sample code which I am trying to get the search
> results
> >
> >     String host = "www.tkdl.res.in";
> >     String searchURI = "/tkdl/langdefault/common/TKDLSearch.asp?GL=Eng";
> >         DefaultHttpClient httpclient = new DefaultHttpClient();
> >
> >         httpclient.getCredentialsProvider().setCredentials(
> >                 new AuthScope("172.31.100.14", 3128),
> >                 new UsernamePasswordCredentials("user", "pass"));
> >
> >         HttpHost targetHost = new HttpHost(host);
> >         HttpHost proxy = new HttpHost("172.31.100.14", 3128);
> >
> >
> httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY,
> > proxy);
> >
> httpclient.getParams().setParameter(ClientPNames.HANDLE_REDIRECTS,
> > false);
> >
>
> Ehhh? You are kidding, right?
>
> Oleg
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>


-- 
Regards
Phani. S

Re: Handling Redirects automatically in HttpClient4.0.1

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Sat, 2010-04-24 at 11:49 +0530, Phani Sajja wrote:
> Hi Oleg,
>          Here is the sample code which I am trying to get the search results
> 
>     String host = "www.tkdl.res.in";
>     String searchURI = "/tkdl/langdefault/common/TKDLSearch.asp?GL=Eng";
>         DefaultHttpClient httpclient = new DefaultHttpClient();
> 
>         httpclient.getCredentialsProvider().setCredentials(
>                 new AuthScope("172.31.100.14", 3128),
>                 new UsernamePasswordCredentials("user", "pass"));
> 
>         HttpHost targetHost = new HttpHost(host);
>         HttpHost proxy = new HttpHost("172.31.100.14", 3128);
> 
>         httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY,
> proxy);
>         httpclient.getParams().setParameter(ClientPNames.HANDLE_REDIRECTS,
> false);
> 

Ehhh? You are kidding, right?

Oleg


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


Re: Handling Redirects automatically in HttpClient4.0.1

Posted by Phani Sajja <sa...@gmail.com>.
Hi Oleg,
         Here is the sample code which I am trying to get the search results

    String host = "www.tkdl.res.in";
    String searchURI = "/tkdl/langdefault/common/TKDLSearch.asp?GL=Eng";
        DefaultHttpClient httpclient = new DefaultHttpClient();

        httpclient.getCredentialsProvider().setCredentials(
                new AuthScope("172.31.100.14", 3128),
                new UsernamePasswordCredentials("user", "pass"));

        HttpHost targetHost = new HttpHost(host);
        HttpHost proxy = new HttpHost("172.31.100.14", 3128);

        httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY,
proxy);
        httpclient.getParams().setParameter(ClientPNames.HANDLE_REDIRECTS,
false);

        HttpPost httpPost = new HttpPost(searchURI);

        List <NameValuePair> nvps = new ArrayList <NameValuePair>();
        nvps.add(new BasicNameValuePair("SearchString", keyword));

        try {
        httpPost.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));
    } catch (UnsupportedEncodingException e1) {
        e1.printStackTrace();
    }

        HttpResponse response = null;
        HttpEntity entity = null;
    try {
        response = httpclient.execute(targetHost, httpPost);
        entity = response.getEntity();
        System.out.println("----------------------------------------");
        System.out.println(response.getStatusLine());
        if (entity != null) {
            System.out.println("Response content length: " +
entity.getContentLength());
            entity.writeTo(System.out);
        }
            if (entity != null) {
                entity.consumeContent();
            }
    }
    catch (ClientProtocolException e) {
        e.printStackTrace();
    }
    catch (IOException e) {
        e.printStackTrace();
    }
Please tell me what went wrong in it.
On Sat, Apr 24, 2010 at 10:30 AM, Phani Sajja <sa...@gmail.com> wrote:

> Hi Oleg,
>        can you give me the sample code that works for you.
>
>
> On Fri, Apr 23, 2010 at 6:07 PM, Oleg Kalnichevski <ol...@apache.org>wrote:
>
>> On Fri, 2010-04-23 at 17:01 +0530, Phani Sajja wrote:
>> > Hi Oleg,
>> >        Here is the complete log
>> >
>>
>> Works without any problem for me
>>
>> [DEBUG] SingleClientConnManager - Get connection for route
>> HttpRoute[{}->http://www.tkdl.res.in]
>> [DEBUG] DefaultHttpClient - Attempt 1 to execute request
>> [DEBUG] DefaultClientConnection - Sending request:
>> GET /tkdl/langdefault/common/home.asp/ HTTP/1.1
>> [DEBUG] headers - >> GET /tkdl/langdefault/common/home.asp/ HTTP/1.1
>> [DEBUG] headers - >> Host: www.tkdl.res.in
>> [DEBUG] headers - >> Connection: Keep-Alive
>> [DEBUG] headers - >> User-Agent: Apache-HttpClient/4.0.1 (java 1.5)
>> [DEBUG] DefaultClientConnection - Receiving response: HTTP/1.1 302
>> Object moved
>> [DEBUG] headers - << HTTP/1.1 302 Object moved
>> [DEBUG] headers - << Connection: close
>> [DEBUG] headers - << Date: Fri, 23 Apr 2010 12:38:42 GMT
>> [DEBUG] headers - << Server: Microsoft-IIS/6.0
>> [DEBUG] headers - << X-Powered-By: ASP.NET
>> [DEBUG] headers - <<
>> Location: /tkdl/includes/errhandler/myeh_500-100.asp?404;
>> http://www.tkdl.res.in/tkdl/langdefault/common/home.asp/
>> [DEBUG] DefaultRedirectHandler - Redirect requested to location
>> '/tkdl/includes/errhandler/myeh_500-100.asp?404;
>> http://www.tkdl.res.in/tkdl/langdefault/common/home.asp/'
>> [DEBUG] DefaultHttpClient - Redirecting to
>> '
>> http://www.tkdl.res.in/tkdl/includes/errhandler/myeh_500-100.asp?404;http://www.tkdl.res.in/tkdl/langdefault/common/home.asp/'
>> via HttpRoute[{}->http://www.tkdl.res.in]
>> [DEBUG] DefaultClientConnection - Connection closed
>> [DEBUG] DefaultHttpClient - Attempt 2 to execute request
>> [DEBUG] DefaultClientConnection - Sending request:
>> GET /tkdl/includes/errhandler/myeh_500-100.asp?404;
>> http://www.tkdl.res.in/tkdl/langdefault/common/home.asp/ HTTP/1.1
>> [DEBUG] headers - >>
>> GET /tkdl/includes/errhandler/myeh_500-100.asp?404;
>> http://www.tkdl.res.in/tkdl/langdefault/common/home.asp/ HTTP/1.1
>> [DEBUG] headers - >> Host: www.tkdl.res.in
>> [DEBUG] headers - >> Connection: Keep-Alive
>> [DEBUG] headers - >> User-Agent: Apache-HttpClient/4.0.1 (java 1.5)
>> [DEBUG] DefaultClientConnection - Receiving response: HTTP/1.1 200 OK
>> [DEBUG] headers - << HTTP/1.1 200 OK
>> [DEBUG] headers - << Date: Fri, 23 Apr 2010 12:38:42 GMT
>> [DEBUG] headers - << Server: Microsoft-IIS/6.0
>> [DEBUG] headers - << X-Powered-By: ASP.NET
>> [DEBUG] headers - << Content-Length: 3413
>> [DEBUG] headers - << Content-Type: text/html
>> [DEBUG] headers - << Set-Cookie:
>> ASPSESSIONIDCSDTRRCT=HHKHPPKADJGPLFGHFDHKCMDH; path=/
>> [DEBUG] headers - << Cache-control: private
>> [DEBUG] DefaultHttpClient - Connection can be kept alive indefinitely
>>
>>
>>
>> > 16:50:57,953 DEBUG SingleClientConnManager:195 - Get connection for
>> route
>> > HttpRoute[{}->http://172.31.100.14:3128->
>> > http://www.tkdl.res.in/tkdl/langdefault/common/home.asp]
>>
>> You have mis-configured HttpClient because it obviously tries to connect
>> to an invalid host
>>
>> http://www.tkdl.res.in/tkdl/langdefault/common/home.asp is not a host,
>> it is a URL.
>>
>> Oleg
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>>
>>
>
>
> --
> Regards
> Phani. S
>
>


-- 
Regards
Phani. S

Re: Handling Redirects automatically in HttpClient4.0.1

Posted by Phani Sajja <sa...@gmail.com>.
Hi Oleg,
       can you give me the sample code that works for you.


On Fri, Apr 23, 2010 at 6:07 PM, Oleg Kalnichevski <ol...@apache.org> wrote:

> On Fri, 2010-04-23 at 17:01 +0530, Phani Sajja wrote:
> > Hi Oleg,
> >        Here is the complete log
> >
>
> Works without any problem for me
>
> [DEBUG] SingleClientConnManager - Get connection for route
> HttpRoute[{}->http://www.tkdl.res.in]
> [DEBUG] DefaultHttpClient - Attempt 1 to execute request
> [DEBUG] DefaultClientConnection - Sending request:
> GET /tkdl/langdefault/common/home.asp/ HTTP/1.1
> [DEBUG] headers - >> GET /tkdl/langdefault/common/home.asp/ HTTP/1.1
> [DEBUG] headers - >> Host: www.tkdl.res.in
> [DEBUG] headers - >> Connection: Keep-Alive
> [DEBUG] headers - >> User-Agent: Apache-HttpClient/4.0.1 (java 1.5)
> [DEBUG] DefaultClientConnection - Receiving response: HTTP/1.1 302
> Object moved
> [DEBUG] headers - << HTTP/1.1 302 Object moved
> [DEBUG] headers - << Connection: close
> [DEBUG] headers - << Date: Fri, 23 Apr 2010 12:38:42 GMT
> [DEBUG] headers - << Server: Microsoft-IIS/6.0
> [DEBUG] headers - << X-Powered-By: ASP.NET
> [DEBUG] headers - <<
> Location: /tkdl/includes/errhandler/myeh_500-100.asp?404;
> http://www.tkdl.res.in/tkdl/langdefault/common/home.asp/
> [DEBUG] DefaultRedirectHandler - Redirect requested to location
> '/tkdl/includes/errhandler/myeh_500-100.asp?404;
> http://www.tkdl.res.in/tkdl/langdefault/common/home.asp/'
> [DEBUG] DefaultHttpClient - Redirecting to
> '
> http://www.tkdl.res.in/tkdl/includes/errhandler/myeh_500-100.asp?404;http://www.tkdl.res.in/tkdl/langdefault/common/home.asp/'
> via HttpRoute[{}->http://www.tkdl.res.in]
> [DEBUG] DefaultClientConnection - Connection closed
> [DEBUG] DefaultHttpClient - Attempt 2 to execute request
> [DEBUG] DefaultClientConnection - Sending request:
> GET /tkdl/includes/errhandler/myeh_500-100.asp?404;
> http://www.tkdl.res.in/tkdl/langdefault/common/home.asp/ HTTP/1.1
> [DEBUG] headers - >>
> GET /tkdl/includes/errhandler/myeh_500-100.asp?404;
> http://www.tkdl.res.in/tkdl/langdefault/common/home.asp/ HTTP/1.1
> [DEBUG] headers - >> Host: www.tkdl.res.in
> [DEBUG] headers - >> Connection: Keep-Alive
> [DEBUG] headers - >> User-Agent: Apache-HttpClient/4.0.1 (java 1.5)
> [DEBUG] DefaultClientConnection - Receiving response: HTTP/1.1 200 OK
> [DEBUG] headers - << HTTP/1.1 200 OK
> [DEBUG] headers - << Date: Fri, 23 Apr 2010 12:38:42 GMT
> [DEBUG] headers - << Server: Microsoft-IIS/6.0
> [DEBUG] headers - << X-Powered-By: ASP.NET
> [DEBUG] headers - << Content-Length: 3413
> [DEBUG] headers - << Content-Type: text/html
> [DEBUG] headers - << Set-Cookie:
> ASPSESSIONIDCSDTRRCT=HHKHPPKADJGPLFGHFDHKCMDH; path=/
> [DEBUG] headers - << Cache-control: private
> [DEBUG] DefaultHttpClient - Connection can be kept alive indefinitely
>
>
>
> > 16:50:57,953 DEBUG SingleClientConnManager:195 - Get connection for route
> > HttpRoute[{}->http://172.31.100.14:3128->
> > http://www.tkdl.res.in/tkdl/langdefault/common/home.asp]
>
> You have mis-configured HttpClient because it obviously tries to connect
> to an invalid host
>
> http://www.tkdl.res.in/tkdl/langdefault/common/home.asp is not a host,
> it is a URL.
>
> Oleg
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>


-- 
Regards
Phani. S

Re: Handling Redirects automatically in HttpClient4.0.1

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Fri, 2010-04-23 at 17:01 +0530, Phani Sajja wrote:
> Hi Oleg,
>        Here is the complete log
> 

Works without any problem for me

[DEBUG] SingleClientConnManager - Get connection for route
HttpRoute[{}->http://www.tkdl.res.in]
[DEBUG] DefaultHttpClient - Attempt 1 to execute request
[DEBUG] DefaultClientConnection - Sending request:
GET /tkdl/langdefault/common/home.asp/ HTTP/1.1
[DEBUG] headers - >> GET /tkdl/langdefault/common/home.asp/ HTTP/1.1
[DEBUG] headers - >> Host: www.tkdl.res.in
[DEBUG] headers - >> Connection: Keep-Alive
[DEBUG] headers - >> User-Agent: Apache-HttpClient/4.0.1 (java 1.5)
[DEBUG] DefaultClientConnection - Receiving response: HTTP/1.1 302
Object moved
[DEBUG] headers - << HTTP/1.1 302 Object moved
[DEBUG] headers - << Connection: close
[DEBUG] headers - << Date: Fri, 23 Apr 2010 12:38:42 GMT
[DEBUG] headers - << Server: Microsoft-IIS/6.0
[DEBUG] headers - << X-Powered-By: ASP.NET
[DEBUG] headers - <<
Location: /tkdl/includes/errhandler/myeh_500-100.asp?404;http://www.tkdl.res.in/tkdl/langdefault/common/home.asp/
[DEBUG] DefaultRedirectHandler - Redirect requested to location
'/tkdl/includes/errhandler/myeh_500-100.asp?404;http://www.tkdl.res.in/tkdl/langdefault/common/home.asp/'
[DEBUG] DefaultHttpClient - Redirecting to
'http://www.tkdl.res.in/tkdl/includes/errhandler/myeh_500-100.asp?404;http://www.tkdl.res.in/tkdl/langdefault/common/home.asp/' via HttpRoute[{}->http://www.tkdl.res.in]
[DEBUG] DefaultClientConnection - Connection closed
[DEBUG] DefaultHttpClient - Attempt 2 to execute request
[DEBUG] DefaultClientConnection - Sending request:
GET /tkdl/includes/errhandler/myeh_500-100.asp?404;http://www.tkdl.res.in/tkdl/langdefault/common/home.asp/ HTTP/1.1
[DEBUG] headers - >>
GET /tkdl/includes/errhandler/myeh_500-100.asp?404;http://www.tkdl.res.in/tkdl/langdefault/common/home.asp/ HTTP/1.1
[DEBUG] headers - >> Host: www.tkdl.res.in
[DEBUG] headers - >> Connection: Keep-Alive
[DEBUG] headers - >> User-Agent: Apache-HttpClient/4.0.1 (java 1.5)
[DEBUG] DefaultClientConnection - Receiving response: HTTP/1.1 200 OK
[DEBUG] headers - << HTTP/1.1 200 OK
[DEBUG] headers - << Date: Fri, 23 Apr 2010 12:38:42 GMT
[DEBUG] headers - << Server: Microsoft-IIS/6.0
[DEBUG] headers - << X-Powered-By: ASP.NET
[DEBUG] headers - << Content-Length: 3413
[DEBUG] headers - << Content-Type: text/html
[DEBUG] headers - << Set-Cookie:
ASPSESSIONIDCSDTRRCT=HHKHPPKADJGPLFGHFDHKCMDH; path=/
[DEBUG] headers - << Cache-control: private
[DEBUG] DefaultHttpClient - Connection can be kept alive indefinitely



> 16:50:57,953 DEBUG SingleClientConnManager:195 - Get connection for route
> HttpRoute[{}->http://172.31.100.14:3128->
> http://www.tkdl.res.in/tkdl/langdefault/common/home.asp]

You have mis-configured HttpClient because it obviously tries to connect
to an invalid host 

http://www.tkdl.res.in/tkdl/langdefault/common/home.asp is not a host,
it is a URL.

Oleg


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


Re: Handling Redirects automatically in HttpClient4.0.1

Posted by Phani Sajja <sa...@gmail.com>.
Hi Oleg,
       Here is the complete log

16:50:57,484 DEBUG PropertyConfigurator:574 - Parsing for [root] with
value=[debug, stdout].
16:50:57,500 DEBUG PropertyConfigurator:589 - Level token is [debug].
16:50:57,500 DEBUG PropertyConfigurator:606 - Category root set to DEBUG.
16:50:57,500 DEBUG PropertyConfigurator:623 - Parsing appender named
"stdout".
16:50:57,531 DEBUG PropertyConfigurator:676 - Parsing layout options for
"stdout".
16:50:57,546 DEBUG PropertySetter:222 - Setting property [conversionPattern]
to [%d{ABSOLUTE} %5p %c{1}:%L - %m%n].
16:50:57,578 DEBUG PropertyConfigurator:684 - End of parsing for "stdout".
16:50:57,578 DEBUG PropertySetter:222 - Setting property [target] to
[System.out].
16:50:57,578 DEBUG PropertyConfigurator:693 - Parsed "stdout" options.
16:50:57,578 DEBUG PropertyConfigurator:389 - Finished configuring.
16:50:57,953 DEBUG SingleClientConnManager:195 - Get connection for route
HttpRoute[{}->http://172.31.100.14:3128->
http://www.tkdl.res.in/tkdl/langdefault/common/home.asp]
16:50:58,000 DEBUG RequestAddCookies:131 - CookieSpec selected: best-match
16:50:58,015 DEBUG DefaultHttpClient:481 - Attempt 1 to execute request
16:50:58,015 DEBUG DefaultClientConnection:244 - Sending request: GET
http://www.tkdl.res.in/tkdl/langdefault/common/home.asp/ HTTP/1.1
16:50:58,015 DEBUG wire:78 - >> "GET
http://www.tkdl.res.in/tkdl/langdefault/common/home.asp/ HTTP/1.1[EOL]"
16:50:58,015 DEBUG wire:78 - >> "Host:
www.tkdl.res.in/tkdl/langdefault/common/home.asp[EOL]"
16:50:58,015 DEBUG wire:78 - >> "Proxy-Connection: Keep-Alive[EOL]"
16:50:58,015 DEBUG wire:78 - >> "User-Agent: Apache-HttpClient/4.0.1 (java
1.5)[EOL]"
16:50:58,015 DEBUG wire:78 - >> "[EOL]"
16:50:58,015 DEBUG headers:248 - >> GET
http://www.tkdl.res.in/tkdl/langdefault/common/home.asp/ HTTP/1.1
16:50:58,031 DEBUG headers:251 - >> Host:
www.tkdl.res.in/tkdl/langdefault/common/home.asp
16:50:58,031 DEBUG headers:251 - >> Proxy-Connection: Keep-Alive
16:50:58,031 DEBUG headers:251 - >> User-Agent: Apache-HttpClient/4.0.1
(java 1.5)
16:50:58,031 DEBUG wire:78 - << "HTTP/1.0 407 Proxy Authentication
Required[EOL]"
16:50:58,031 DEBUG wire:78 - << "Server: squid[EOL]"
16:50:58,031 DEBUG wire:78 - << "Mime-Version: 1.0[EOL]"
16:50:58,031 DEBUG wire:78 - << "Date: Fri, 23 Apr 2010 11:28:54 GMT[EOL]"
16:50:58,031 DEBUG wire:78 - << "Content-Type: text/html[EOL]"
16:50:58,031 DEBUG wire:78 - << "Content-Length: 1722[EOL]"
16:50:58,031 DEBUG wire:78 - << "X-Squid-Error: ERR_CACHE_ACCESS_DENIED
0[EOL]"
16:50:58,031 DEBUG wire:78 - << "Proxy-Authenticate: Basic realm="Enter Your
Username and password"[EOL]"
16:50:58,031 DEBUG wire:78 - << "X-Cache: MISS from proxyserver[EOL]"
16:50:58,046 DEBUG wire:78 - << "Via: 1.0 proxyserver (squid)[EOL]"
16:50:58,046 DEBUG wire:78 - << "Proxy-Connection: close[EOL]"
16:50:58,046 DEBUG wire:78 - << "[EOL]"
16:50:58,046 DEBUG DefaultClientConnection:229 - Receiving response:
HTTP/1.0 407 Proxy Authentication Required
16:50:58,046 DEBUG headers:232 - << HTTP/1.0 407 Proxy Authentication
Required
16:50:58,046 DEBUG headers:235 - << Server: squid
16:50:58,046 DEBUG headers:235 - << Mime-Version: 1.0
16:50:58,046 DEBUG headers:235 - << Date: Fri, 23 Apr 2010 11:28:54 GMT
16:50:58,046 DEBUG headers:235 - << Content-Type: text/html
16:50:58,046 DEBUG headers:235 - << Content-Length: 1722
16:50:58,046 DEBUG headers:235 - << X-Squid-Error: ERR_CACHE_ACCESS_DENIED 0
16:50:58,046 DEBUG headers:235 - << Proxy-Authenticate: Basic realm="Enter
Your Username and password"
16:50:58,046 DEBUG headers:235 - << X-Cache: MISS from proxyserver
16:50:58,046 DEBUG headers:235 - << Via: 1.0 proxyserver (squid)
16:50:58,046 DEBUG headers:235 - << Proxy-Connection: close
16:50:58,046 DEBUG DefaultHttpClient:1054 - Proxy requested authentication
16:50:58,046 DEBUG DefaultProxyAuthenticationHandler:132 - Authentication
schemes in the order of preference: [ntlm, digest, basic]
16:50:58,046 DEBUG DefaultProxyAuthenticationHandler:155 - Challenge for
ntlm authentication scheme not available
16:50:58,046 DEBUG DefaultProxyAuthenticationHandler:155 - Challenge for
digest authentication scheme not available
16:50:58,046 DEBUG DefaultProxyAuthenticationHandler:142 - basic
authentication scheme selected
16:50:58,062 DEBUG DefaultHttpClient:1134 - Authorization challenge
processed
16:50:58,062 DEBUG DefaultHttpClient:1162 - Authentication scope: BASIC
'Enter Your Username and password'@172.31.100.14:3128
16:50:58,062 DEBUG DefaultHttpClient:1169 - Found credentials
16:50:58,062 DEBUG DefaultClientConnection:153 - Connection closed
16:50:58,078 DEBUG RequestAddCookies:131 - CookieSpec selected: best-match
16:50:58,093 DEBUG DefaultHttpClient:481 - Attempt 2 to execute request
16:50:58,093 DEBUG DefaultClientConnection:244 - Sending request: GET
http://www.tkdl.res.in/tkdl/langdefault/common/home.asp/ HTTP/1.1
16:50:58,093 DEBUG wire:78 - >> "GET
http://www.tkdl.res.in/tkdl/langdefault/common/home.asp/ HTTP/1.1[EOL]"
16:50:58,093 DEBUG wire:78 - >> "Host:
www.tkdl.res.in/tkdl/langdefault/common/home.asp[EOL]"
16:50:58,187 DEBUG wire:78 - >> "Proxy-Connection: Keep-Alive[EOL]"
16:50:58,187 DEBUG wire:78 - >> "User-Agent: Apache-HttpClient/4.0.1 (java
1.5)[EOL]"
16:50:58,187 DEBUG wire:78 - >> "Proxy-Authorization: Basic
cGhhbmk6c2FqamFAMQ==[EOL]"
16:50:58,187 DEBUG wire:78 - >> "[EOL]"
16:50:58,187 DEBUG headers:248 - >> GET
http://www.tkdl.res.in/tkdl/langdefault/common/home.asp/ HTTP/1.1
16:50:58,187 DEBUG headers:251 - >> Host:
www.tkdl.res.in/tkdl/langdefault/common/home.asp
16:50:58,187 DEBUG headers:251 - >> Proxy-Connection: Keep-Alive
16:50:58,203 DEBUG headers:251 - >> User-Agent: Apache-HttpClient/4.0.1
(java 1.5)
16:50:58,203 DEBUG headers:251 - >> Proxy-Authorization: Basic
cGhhbmk6c2FqamFAMQ==
16:50:58,343 DEBUG wire:78 - << "HTTP/1.0 302 Moved Temporarily[EOL]"
16:50:58,343 DEBUG wire:78 - << "Date: Fri, 23 Apr 2010 11:32:12 GMT[EOL]"
16:50:58,343 DEBUG wire:78 - << "Server: Microsoft-IIS/6.0[EOL]"
16:50:58,343 DEBUG wire:78 - << "X-Powered-By: ASP.NET[EOL]"
16:50:58,343 DEBUG wire:78 - << "Location:
/tkdl/includes/errhandler/myeh_500-100.asp?404;
http://www.tkdl.res.in/tkdl/langdefault/common/home.asp/[EOL]"
16:50:58,343 DEBUG wire:78 - << "X-Cache: MISS from proxyserver[EOL]"
16:50:58,343 DEBUG wire:78 - << "Via: 1.0 proxyserver (squid)[EOL]"
16:50:58,343 DEBUG wire:78 - << "Proxy-Connection: close[EOL]"
16:50:58,343 DEBUG wire:78 - << "[EOL]"
16:50:58,343 DEBUG DefaultClientConnection:229 - Receiving response:
HTTP/1.0 302 Moved Temporarily
16:50:58,343 DEBUG headers:232 - << HTTP/1.0 302 Moved Temporarily
16:50:58,343 DEBUG headers:235 - << Date: Fri, 23 Apr 2010 11:32:12 GMT
16:50:58,343 DEBUG headers:235 - << Server: Microsoft-IIS/6.0
16:50:58,343 DEBUG headers:235 - << X-Powered-By: ASP.NET
16:50:58,343 DEBUG headers:235 - << Location:
/tkdl/includes/errhandler/myeh_500-100.asp?404;
http://www.tkdl.res.in/tkdl/langdefault/common/home.asp/
16:50:58,343 DEBUG headers:235 - << X-Cache: MISS from proxyserver
16:50:58,343 DEBUG headers:235 - << Via: 1.0 proxyserver (squid)
16:50:58,343 DEBUG headers:235 - << Proxy-Connection: close
----------------------------------------
HTTP/1.0 302 Moved Temporarily
Response content length: -1
16:50:58,359 DEBUG SingleClientConnManager:250 - Releasing connection
org.apache.http.impl.conn.SingleClientConnManager$ConnAdapter@8fce95
16:50:58,359 DEBUG SingleClientConnManager:268 - Released connection open
but not reusable.
16:50:58,359 DEBUG DefaultClientConnection:141 - Connection shut down



On Fri, Apr 23, 2010 at 3:45 PM, Oleg Kalnichevski <ol...@apache.org> wrote:

> On Fri, 2010-04-23 at 15:02 +0530, Phani Sajja wrote:
> > Hi all,
> >         I am using HttpClient version 4.0.1. When I execute a method on a
> > link I am getting error 302 saying HTTP/1.0 302 Moved Temporarily. How to
> > handle redirects automatically so that I can get the final page. Help me
> > please!
> >
>
> Generate a wire log of the HTTP session that exhibits the problem, as
> described below, and post the log to this list:
>
> http://hc.apache.org/httpcomponents-client-4.0.1/logging.html
>
> Oleg
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>


-- 
Regards
Phani. S

Re: Handling Redirects automatically in HttpClient4.0.1

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Fri, 2010-04-23 at 15:02 +0530, Phani Sajja wrote:
> Hi all,
>         I am using HttpClient version 4.0.1. When I execute a method on a
> link I am getting error 302 saying HTTP/1.0 302 Moved Temporarily. How to
> handle redirects automatically so that I can get the final page. Help me
> please!
> 

Generate a wire log of the HTTP session that exhibits the problem, as
described below, and post the log to this list:

http://hc.apache.org/httpcomponents-client-4.0.1/logging.html

Oleg





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