DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=24514>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=24514 HEAD Method, IIS and Cookies Summary: HEAD Method, IIS and Cookies Product: Commons Version: 2.0 Milestone 2 Platform: PC OS/Version: Windows XP Status: NEW Severity: Normal Priority: Other Component: HttpClient AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] I'm trying to execute the HeadMethod against a secured (forms based) Microsoft IIS 5.0 server. When I execute the HEAD method, a cookie should be sent along with the request indicating that I'm authorized to access the resource. Everything works fine for the GetMethod! Here's the code I'm using: import java.io.IOException; import java.net.URL; import org.apache.commons.httpclient.*; import org.apache.commons.httpclient.methods.*; import org.apache.commons.httpclient.util.*; public class TestHeadMethod { private final static String URL = "https://my.webserver.com/SomeResource.jar"; public static void main( String[] args ) throws IOException, HttpException { System.setProperty ( "apache.commons.httpclient.cookiespec", "COMPATIBILITY" ); HttpClient client = new HttpClient(); PostMethod httpPost = new PostMethod ( "https://my.webserver.com/siteminderagent/forms/login/Login.fcc" ); httpPost.addParameter( "target", "$SM$" + URL ); httpPost.addParameter( "USER", "foo" ); httpPost.addParameter( "PASSWORD", "bar" ); httpPost.addParameter( "smauthreason", "0" ); // Execute HTTP POST client.executeMethod( httpPost ); httpPost.releaseConnection(); HttpMethod method = new HeadMethod( URL ); client.executeMethod( method ); HttpURLConnection urlConn = new HttpURLConnection( method, new URL( URL ) ); System.out.println( "Get Last Modified: " + urlConn.getLastModified () ); } } Note from the log that a redirect occurs when the connection is not authorized. In other words, if you make a connection and the authorization cookie is not present and valid, you are redirected to the login page. 2003/11/07 09:07:22:054 PST [DEBUG] HttpMethodBase - -Resorting to protocol version default close connection policy 2003/11/07 09:07:22:054 PST [DEBUG] HttpMethodBase - -Should NOT close connection, using HTTP/1.1 2003/11/07 09:07:22:054 PST [DEBUG] HttpConnection - -Releasing connection back to connection manager. 2003/11/07 09:07:22:064 PST [DEBUG] DefaultHttpParams - -Set parameter http.protocol.unambiguous-statusline = false 2003/11/07 09:07:22:064 PST [DEBUG] DefaultHttpParams - -Set parameter http.protocol.single-cookie-header = false 2003/11/07 09:07:22:064 PST [DEBUG] DefaultHttpParams - -Set parameter http.protocol.strict-transfer-encoding = false 2003/11/07 09:07:22:064 PST [DEBUG] DefaultHttpParams - -Set parameter http.protocol.reject-head-body = false 2003/11/07 09:07:22:064 PST [DEBUG] HttpMethodDirector - -Execute loop try 1 2003/11/07 09:07:22:074 PST [DEBUG] wire - ->> "HEAD /SomeResource.jar HTTP/1.1 [\r][\n]" 2003/11/07 09:07:22:074 PST [DEBUG] HttpMethodBase - -Adding Host request header 2003/11/07 09:07:22:074 PST [DEBUG] wire - ->> "User-Agent: Jakarta Commons- HttpClient[\r][\n]" 2003/11/07 09:07:22:074 PST [DEBUG] wire - ->> "Host: my.webserver.com[\r][\n]" 2003/11/07 09:07:22:074 PST [DEBUG] wire - ->> "Cookie: $Version=0; SMSESSION=4B1ILNFFZ7fckLdd/ACXINNZJoUKX1R/llARuQO8JvU10eDz/Du9gCIcveUCRs9e2RTi9 B9hr/xdj1IETXPWqT7GNJsE5NlgvhB1eMRnyjnwqfg/+8JlH47Oy7Z5zUHGDgccr34GofACSuioXzXl MHOqy+WmXHriPz/K/d+YLaD7VCtoLyo07kW91Sl6UmWHutkUJ9I0zixlhftDvdUmTbxGOWTGrPbIUIT FLHWhmnO2LVjDHkOjHepkQlcHz+e6Ka+Qes0EvyMUKqRgeqaEGws+GFWtkBLSAT3R1KMbUkZeoFJPN2 KbUGc+WouswZYh5nLyE2YG6f5EkZa5Ozg2Ip1KFibR+4J3XakyP4M4J93aN5qomL99qRQ8vv5RLPRkR de6sPvVuYCooWtR+MPu+maKTq6dt0x48MbhGUBxYlYr9PpyQ38f/tP3ARKE01zH5PBh8ZYrm0PqYMDh 8lGMGisfjtCUdYAnypo0Z0c3KXub3AEh8ecOKDObljhmusXdTA4yftzYy0tpAGMHHxZcGRLJCpzG3Im /o6z9/dSQTlppb/1xAj60vTqdU/fg6L70vL52UCxiRQYuzO5c3i7+k+nkGXOvhYTCZoARWkIgBrebz/ ABkEQF7SkdGWsdEmmgaKx8LumzI5qVWxT4mfqxjRhYqv6GsntPZeK/O6Mku5HBfDl1h60/386MgWi1T 5d+; $Domain=.webserver.com; $Path=/[\r][\n]" 2003/11/07 09:07:22:084 PST [DEBUG] wire - ->> "[\r][\n]" 2003/11/07 09:07:22:274 PST [DEBUG] wire - -<< "HTTP/1.1 302 Object Moved[\r] [\n]" 2003/11/07 09:07:22:274 PST [DEBUG] DefaultHttpParams - -Set parameter http.protocol.version = HTTP/1.1 2003/11/07 09:07:22:274 PST [DEBUG] wire - -<< "Location: http://my.webserver.com/siteminderagent/forms/login.fcc? TYPE=33554433&REALMOID=06-2fcd47ba-acbf-4e58-a0ce- 0cbb02aab8d9&GUID=&SMAUTHREASON=0&TARGET=http://my.webserver.com/SomeResource.j ar[\r][\n]" 2003/11/07 09:07:22:274 PST [DEBUG] HttpMethodBase - -Resorting to protocol version default close connection policy 2003/11/07 09:07:22:274 PST [DEBUG] HttpMethodBase - -Should NOT close connection, using HTTP/1.1 2003/11/07 09:07:22:274 PST [DEBUG] HttpConnection - -Connection is locked. Call to releaseConnection() ignored. 2003/11/07 09:07:22:274 PST [DEBUG] HttpMethodDirector - -Redirect required 2003/11/07 09:07:22:274 PST [DEBUG] HttpMethodDirector - -Redirect requested to location 'http://my.webserver.com/siteminderagent/forms/login.fcc? TYPE=33554433&REALMOID=06-2fcd47ba-acbf-4e58-a0ce- 0cbb02aab8d9&GUID=&SMAUTHREASON=0&TARGET=http://my.webserver.com/SomeResource.j ar' 2003/11/07 09:07:22:284 PST [DEBUG] HttpMethodDirector - -Redirecting from 'http://my.webserver.com:80/SomeResource.jar' to 'http://my.webserver.com/siteminderagent/forms/login.fcc? TYPE=33554433&REALMOID=06-2fcd47ba-acbf-4e58-a0ce- 0cbb02aab8d9&GUID=&SMAUTHREASON=0&TARGET=http://my.webserver.com/SomeResource.j ar 2003/11/07 09:07:22:284 PST [DEBUG] HttpMethodDirector - -Execute loop try 2 2003/11/07 09:07:22:284 PST [DEBUG] wire - - >> "HEAD /siteminderagent/forms/login.fcc?TYPE=33554433&REALMOID=06-2fcd47ba- acbf-4e58-a0ce- 0cbb02aab8d9&GUID=&SMAUTHREASON=0&TARGET=http://my.webserver.com/SomeResource.j ar HTTP/1.1[\r][\n]" 2003/11/07 09:07:22:284 PST [DEBUG] HttpMethodBase - -Adding Host request header 2003/11/07 09:07:22:284 PST [DEBUG] wire - ->> "User-Agent: Jakarta Commons- HttpClient[\r][\n]" 2003/11/07 09:07:22:284 PST [DEBUG] wire - ->> "Host: my.webserver.com[\r][\n]" 2003/11/07 09:07:22:284 PST [DEBUG] wire - ->> "Cookie: $Version=0; SMSESSION=4B1ILNFFZ7fckLdd/ACXINNZJoUKX1R/llARuQO8JvU10eDz/Du9gCIcveUCRs9e2RTi9 B9hr/xdj1IETXPWqT7GNJsE5NlgvhB1eMRnyjnwqfg/+8JlH47Oy7Z5zUHGDgccr34GofACSuioXzXl MHOqy+WmXHriPz/K/d+YLaD7VCtoLyo07kW91Sl6UmWHutkUJ9I0zixlhftDvdUmTbxGOWTGrPbIUIT FLHWhmnO2LVjDHkOjHepkQlcHz+e6Ka+Qes0EvyMUKqRgeqaEGws+GFWtkBLSAT3R1KMbUkZeoFJPN2 KbUGc+WouswZYh5nLyE2YG6f5EkZa5Ozg2Ip1KFibR+4J3XakyP4M4J93aN5qomL99qRQ8vv5RLPRkR de6sPvVuYCooWtR+MPu+maKTq6dt0x48MbhGUBxYlYr9PpyQ38f/tP3ARKE01zH5PBh8ZYrm0PqYMDh 8lGMGisfjtCUdYAnypo0Z0c3KXub3AEh8ecOKDObljhmusXdTA4yftzYy0tpAGMHHxZcGRLJCpzG3Im /o6z9/dSQTlppb/1xAj60vTqdU/fg6L70vL52UCxiRQYuzO5c3i7+k+nkGXOvhYTCZoARWkIgBrebz/ ABkEQF7SkdGWsdEmmgaKx8LumzI5qVWxT4mfqxjRhYqv6GsntPZeK/O6Mku5HBfDl1h60/386MgWi1T 5d+; $Domain=.webserver.com; $Path=/[\r][\n]" 2003/11/07 09:07:22:294 PST [DEBUG] wire - ->> "[\r][\n]" 2003/11/07 09:07:22:294 PST [DEBUG] wire - -<< "[\r][\n]" 2003/11/07 09:07:22:294 PST [DEBUG] HttpMethodDirector - -Closing the connection. 2003/11/07 09:07:22:294 PST [INFO] HttpMethodDirector - -Recoverable exception caught when processing request 2003/11/07 09:07:22:384 PST [DEBUG] wire - - >> "HEAD /siteminderagent/forms/login.fcc?TYPE=33554433&REALMOID=06-2fcd47ba- acbf-4e58-a0ce- 0cbb02aab8d9&GUID=&SMAUTHREASON=0&TARGET=http://my.webserver.com/SomeResource.j ar HTTP/1.1[\r][\n]" 2003/11/07 09:07:22:384 PST [DEBUG] HttpMethodBase - -Adding Host request header 2003/11/07 09:07:22:384 PST [DEBUG] wire - ->> "User-Agent: Jakarta Commons- HttpClient[\r][\n]" 2003/11/07 09:07:22:384 PST [DEBUG] wire - ->> "Host: my.webserver.com[\r][\n]" 2003/11/07 09:07:22:384 PST [DEBUG] wire - ->> "Cookie: $Version=0; SMSESSION=4B1ILNFFZ7fckLdd/ACXINNZJoUKX1R/llARuQO8JvU10eDz/Du9gCIcveUCRs9e2RTi9 B9hr/xdj1IETXPWqT7GNJsE5NlgvhB1eMRnyjnwqfg/+8JlH47Oy7Z5zUHGDgccr34GofACSuioXzXl MHOqy+WmXHriPz/K/d+YLaD7VCtoLyo07kW91Sl6UmWHutkUJ9I0zixlhftDvdUmTbxGOWTGrPbIUIT FLHWhmnO2LVjDHkOjHepkQlcHz+e6Ka+Qes0EvyMUKqRgeqaEGws+GFWtkBLSAT3R1KMbUkZeoFJPN2 KbUGc+WouswZYh5nLyE2YG6f5EkZa5Ozg2Ip1KFibR+4J3XakyP4M4J93aN5qomL99qRQ8vv5RLPRkR de6sPvVuYCooWtR+MPu+maKTq6dt0x48MbhGUBxYlYr9PpyQ38f/tP3ARKE01zH5PBh8ZYrm0PqYMDh 8lGMGisfjtCUdYAnypo0Z0c3KXub3AEh8ecOKDObljhmusXdTA4yftzYy0tpAGMHHxZcGRLJCpzG3Im /o6z9/dSQTlppb/1xAj60vTqdU/fg6L70vL52UCxiRQYuzO5c3i7+k+nkGXOvhYTCZoARWkIgBrebz/ ABkEQF7SkdGWsdEmmgaKx8LumzI5qVWxT4mfqxjRhYqv6GsntPZeK/O6Mku5HBfDl1h60/386MgWi1T 5d+; $Domain=.webserver.com; $Path=/[\r][\n]" 2003/11/07 09:07:22:384 PST [DEBUG] wire - ->> "[\r][\n]" 2003/11/07 09:07:22:504 PST [DEBUG] wire - -<< "HTTP/1.1 200 OK[\r][\n]" 2003/11/07 09:07:22:504 PST [DEBUG] DefaultHttpParams - -Set parameter http.protocol.version = HTTP/1.1 2003/11/07 09:07:22:504 PST [DEBUG] wire - -<< "Server: Microsoft-IIS/5.0[\r] [\n]" 2003/11/07 09:07:22:504 PST [DEBUG] wire - -<< "Date: Fri, 07 Nov 2003 17:07:22 GMT[\r][\n]" 2003/11/07 09:07:22:504 PST [DEBUG] wire - -<< "Connection: close[\r][\n]" 2003/11/07 09:07:22:504 PST [DEBUG] HttpMethodBase - -Should close connection in response to Connection: close --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]