Hello Jean-Remi,

1. make the POST request
2. look for the "Location" header
3. make the GET request to the Location

The output you copied shows only the requests you send.
The Location header is not in the request, it is in the
response to step 1. Therefore, I suspect you made a
mistake in step 2, possibly by looking in the wrong place.
You need to do the following:

Header location = postMethod.getResponseHeader("Location");

where 'postMethod' is the method you executed in step 1.

I hope this helps,
  Roland








"JEAN REMI LECQ" <[EMAIL PROTECTED]>
29.01.2004 14:56
Please respond to "Commons HttpClient Project"
 
        To:     "Commons HttpClient Project" 
<[EMAIL PROTECTED]>
        cc: 
        Subject:        PostMethod.setFollowRedirects(true); -> do nothing


Sorry to come again with the same question, but I do not know what to 
do...
I read carefully your replies and do what you said but...

My problem is that I have to send my first GET request to a specific URL 
(I
can not modify that, it is not mine), this page fill a form with my
parameters and submit them automatically to an another URL (in the same
domaine, I know this second URL). The submission is automatic and is in 
POST
methode, I have to follow it to catch the resuls...

I catched the cookies.

I tried to make the first request in POST to send my parameters and make 
the
second in GET to the forward
URL(http://www.XXX.com/mirror/etape2h.cfm?ref=0144259402). But I have 
always
the same error message even if I put the setFollowRedirects method at TRUE 
:
>29 janv. 2004 14:53:33 org.apache.commons.httpclient.HttpMethodBase
processRedirectResponse
>INFO: Redirect requested but followRedirects is disabled

I also tried to make the first request under POST for catching the
"location" header, but there is nothing like that in anyone of the
redirection:
GET
http://www.XXX.com/mirror/listehotels.cfm?&Vilarr=MRS&DatDep=300104&DatArr=0

10204&Adultes=2&ENFANTS=0&BEBES=0&ref=0144259402 HTTP/1.0
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
application/x-shockwave-flash, application/vnd.ms-powerpoint,
application/vnd.ms-excel, application/msword, */*
Accept-Language: fr
Cookie: CFID=41696517; CFTOKEN=19746368
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
Host: www.XXX.com
Proxy-Connection: Keep-Alive

POST http://www.XXX.com/mirror/etape2h.cfm?ref=0144259402 HTTP/1.0
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
application/x-shockwave-flash, application/vnd.ms-powerpoint,
application/vnd.ms-excel, application/msword, */*
Referer:
http://www.XXX.com/mirror/listehotels.cfm?&Vilarr=MRS&DatDep=300104&DatArr=0

10204&Adultes=2&ENFANTS=0&BEBES=0&ref=0144259402
Accept-Language: fr
Content-Type: application/x-www-form-urlencoded
Proxy-Connection: Keep-Alive
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
Host: www.XXX.com
Content-Length: 234
Pragma: no-cache
Cookie: CFID=41696517; CFTOKEN=19746368

destination=228&Date_Depart=30%2F01%2F2004&Date_Retour=01%2F02%2F2004&Date_D
epart_h=30%2F01%2F2004&Date_Retour_h=01%2F02%2F2004&AllerRetour=1&ADULTES=2&
ENFANTS=0&BEBES=0&dated=300104&dater=010204&ref=0144259402&codego=261&ville_
hotel=GET http://www.XXX.com/mirror/habillage_go/page/styleaac.css 
HTTP/1.0
Accept: */*
Referer: http://www.XXX.com/mirror/etape2h.cfm?ref=0144259402
Accept-Language: fr
Proxy-Connection: Keep-Alive
If-Modified-Since: Tue, 13 Jan 2004 16:25:09 GMT
If-None-Match: "d1062f51-1-b4c-40041be5"
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
Host: www.XXX.com
Cookie: CFID=41696517; CFTOKEN=19746368

help... :-(

jeanremi

-----Message d'origine-----
De : Ortwin Glück [mailto:[EMAIL PROTECTED]
Envoyé : mercredi 21 janvier 2004 08:35
À : Commons HttpClient Project
Objet : Re: PostMethod.setFollowRedirects(true); -> do nothing




Eric Johnson wrote:
>  Redirect on a POST request
> is *not supported*
> This stems from fundamental architectural limitations of the current
> HttpClient 2.0 design.


Actually the problem is two-fold:

1. "redirect" in HttpClient means: The *same* request ist sent to a
    different URL (on the same host). The HTTP Protocol (RFC 2616)
explicitly
    forbids this kind of redirection for entity enclosing methods
    without any user interaction. That's why the flag is set to false.

2. A Location (redirect) header as a response to a POST request
    is handled as a GET request to the new URL by browsers. HttpClients
design
    does not currently allow chaning the method on the fly. That's why you
    need to handle this yourself.

Odi
--
  _________________________________________________________________
  NOSE applied intelligence ag

  ortwin glück                      [www]      http://www.nose.ch
  software engineer                 [email] [EMAIL PROTECTED]
  hardturmstrasse 171               [pgp key]          0x81CF3416
  8005 zürich                       [office]      +41-1-277 57 35
  switzerland                       [fax]         +41-1-277 57 12

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



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


Reply via email to