Return-Path: Delivered-To: apmail-jakarta-commons-user-archive@www.apache.org Received: (qmail 18109 invoked from network); 7 Sep 2004 17:39:57 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 7 Sep 2004 17:39:57 -0000 Received: (qmail 55013 invoked by uid 500); 7 Sep 2004 17:39:20 -0000 Delivered-To: apmail-jakarta-commons-user-archive@jakarta.apache.org Received: (qmail 54851 invoked by uid 500); 7 Sep 2004 17:39:19 -0000 Mailing-List: contact commons-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Users List" Reply-To: "Jakarta Commons Users List" Delivered-To: mailing list commons-user@jakarta.apache.org Received: (qmail 54713 invoked by uid 99); 7 Sep 2004 17:39:18 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=WEIRD_PORT X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from [195.186.1.207] (HELO mail5.bluewin.ch) (195.186.1.207) by apache.org (qpsmtpd/0.28) with ESMTP; Tue, 07 Sep 2004 10:39:16 -0700 Received: from [192.168.0.2] (62.202.95.88) by mail5.bluewin.ch (Bluewin AG 7.0.030.2) id 412F8F2D00155AC7 for commons-user@jakarta.apache.org; Tue, 7 Sep 2004 17:39:13 +0000 Subject: RE: [HttpClient] How to use HttpClient with Form-based Authentication? From: Oleg Kalnichevski To: Jakarta Commons Users List In-Reply-To: References: Content-Type: text/plain Message-Id: <1094578752.9142.7.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Date: Tue, 07 Sep 2004 19:39:12 +0200 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N The problem is not the redirect as such. The real issue appears to be that for whatever reason the upload servlet does not recognize or accept the session cookie which causes the redirect back to the logon page Please post the complete debug/wire log of the HTTP session that exhibits the problem. For details on logging with HttpClient refer to the HttpClient logging guide: http://jakarta.apache.org/commons/httpclient/logging.html I'll see if I can get more information out of the wire log. You may want to have security sensitive information such as logon credentials obfuscated prior to posting the log to the list Oleg On Tue, 2004-09-07 at 15:50, rportan@saguaro.ro wrote: > Thank for help, sadly is not enogh. > I want to upload several files using MultipartPostMethod, the problem is > I'm redirected from the upload servlet back to the login form page. > Basicaly I want my client to authorize itself and than go the > UploadServlet to send the file to it. > > > Here is my addition(BOLDED) to the FormLoginDemo.java file. > > > ... > > > if ((statuscode == HttpStatus.SC_MOVED_TEMPORARILY) || > (statuscode == HttpStatus.SC_MOVED_PERMANENTLY) || > (statuscode == HttpStatus.SC_SEE_OTHER) || > (statuscode == HttpStatus.SC_TEMPORARY_REDIRECT)) { > Header header = authpost.getResponseHeader("location"); > if (header != null) { > String newuri = header.getValue(); > if ((newuri == null) || (newuri.equals(""))) { > newuri = "/"; > } > System.out.println("Redirect target: " + newuri); > GetMethod redirect = new GetMethod(newuri); > > client.executeMethod(redirect); > System.out.println("Redirect: " + > redirect.getStatusLine().toString()); > // release any connection resources used by the method > redirect.releaseConnection(); > > > > File file=new File("c:\\Books\\"); > MultipartPostMethod mPost = new MultipartPostMethod( > "http://localhost/MyApp/UploadServlet"); > mPost.addParameter(file.getName(),file); > mPost.setFollowRedirects(true); > > client.executeMethod(mPost); > System.out.println("Post status: " + > mPost.getStatusLine().toString()); > mPost.releaseConnection(); > > > > } else { > System.out.println("Invalid redirect"); > System.exit(1); > } > } > ......... > > > > And here are the logs for multipart request part: > > > > 2004/09/07 16:46:14:922 EEST [INFO] HttpMethodDirector - Redirect > requested but followRedirects is disabledLogin form post: HTTP/1.1 302 > Found > > Logon cookies: > - JSESSIONID=0000SdkoAaLYJd1wXxn-19q17Fe:-1 > Redirect target: http://localhost:9080/InfoprintJobTicketer/login.html > 2004/09/07 16:46:14:922 EEST [DEBUG] HttpMethodBase - Resorting to > protocol version default close connection policy > 2004/09/07 16:46:14:922 EEST [DEBUG] HttpMethodBase - Should NOT close > connection, using HTTP/1.1 > 2004/09/07 16:46:14:922 EEST [DEBUG] HttpConnection - Releasing connection > back to connection manager. > Redirect: HTTP/1.1 200 OK > 2004/09/07 16:46:14:922 EEST [DEBUG] HttpMethodBase - Adding Host request > header > 2004/09/07 16:46:14:938 EEST [DEBUG] HttpMethodBase - Resorting to > protocol version default close connection policy > 2004/09/07 16:46:14:938 EEST [DEBUG] HttpMethodBase - Should NOT close > connection, using HTTP/1.1 > 2004/09/07 16:46:14:938 EEST [DEBUG] HttpConnection - Releasing connection > back to connection manager. > 2004/09/07 16:46:14:953 EEST [DEBUG] HttpMethodBase - Adding Host request > header > 2004/09/07 16:46:16:250 EEST [DEBUG] HttpMethodDirector - Redirect > required > 2004/09/07 16:46:16:250 EEST [DEBUG] HttpMethodDirector - Redirect > requested to location > 'http://localhost:9080/InfoprintJobTicketer/login.html' > 2004/09/07 16:46:16:250 EEST [DEBUG] HttpMethodDirector - Redirecting from > 'http://localhost/MyApp/UploadServlet' to 'http://localhost/MyApp/ > login.html > 2004/09/07 16:46:16:250 EEST [DEBUG] HttpMethodDirector - Execute redirect > 1 of 100 > 2004/09/07 16:46:16:250 EEST [DEBUG] HttpMethodBase - Resorting to > protocol version default close connection policy > 2004/09/07 16:46:16:250 EEST [DEBUG] HttpMethodBase - Should NOT close > connection, using HTTP/1.1 > 2004/09/07 16:46:16:250 EEST [DEBUG] HttpConnection - Connection is > locked. Call to releaseConnection() ignored. > 2004/09/07 16:46:16:266 EEST [DEBUG] HttpMethodBase - Adding Host request > header > 2004/09/07 16:46:17:109 EEST [DEBUG] HttpMethodBase - Resorting to > protocol version default close connection policy > 2004/09/07 16:46:17:109 EEST [DEBUG] HttpMethodBase - Should NOT close > connection, using HTTP/1.1 > 2004/09/07 16:46:17:109 EEST [DEBUG] HttpConnection - Releasing connection > back to connection manager. > Post status: HTTP/1.1 200 OK > > > > > > olegk@bluewin.ch > 09/07/2004 03:57 PM > Please respond to > "Jakarta Commons Users List" > > > To > "Jakarta Commons Users List" > cc > > Subject > RE: [HttpClient] How to use HttpClient with Form-based Authentication? > > > > > > > Hope this one will do > > http://cvs.apache.org/viewcvs.cgi/jakarta-commons/httpclient/src/examples/FormLoginDemo.java?view=markup > > > Oleg > > >-- Original Message -- > >Reply-To: "Jakarta Commons Users List" > >To: commons-user@jakarta.apache.org > >Subject: [HttpClient] How to use HttpClient with Form-based > Authentication? > >From: rportan@saguaro.ro > >Date: Tue, 7 Sep 2004 15:50:02 +0300 > > > > > >Hi, > > > >Can HttpClient be used with Form-based Authentication? > >If yes can I have a code example? > >Thank you > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org > For additional commands, e-mail: commons-user-help@jakarta.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-user-help@jakarta.apache.org