Currently, in org.apache.webdav.lib.WebdavClient.executeMethod(..), the
following things happen in the following order:
1. sendRequest(method);
2. if(! http11) -> closeOutput
3. parseStatusLine(..)
The http11 flag (false by default) is actually set in #3 parseStatusLine, so
the first request is always treated as NOT http11. I'm not really sure why,
but it seems to prevent being able to connect to servers that require
authentication?!?
All that is required to fix this is to switch 2 and 3.
i.e. 1. sendRequest(method);
2. parseStatusLine(..)
3. if(! http11) -> closeOutput
So, instead of this...
boolean closeOutput = needToCloseOutput();
if (closeOutput) {
try {
Class[] paramsClasses = new Class[0];
Method shutdownOutput = socket.getClass().getMethod
("shutdownOutput", paramsClasses);
Object[] params = new Object[0];
shutdownOutput.invoke(socket, params);
} catch (Exception e) {
// Ignore, and hope everything goes right
}
}
// Parse status line
String statusLine = readLine(input);
if (statusLine == null)
throw new IOException("Couldn't parse status line");
parseStatusLine(statusLine, method);
do this...
// Parse status line
String statusLine = readLine(input);
if (statusLine == null)
throw new IOException("Couldn't parse status line");
parseStatusLine(statusLine, method);
boolean closeOutput = needToCloseOutput();
if (closeOutput) {
try {
Class[] paramsClasses = new Class[0];
Method shutdownOutput = socket.getClass().getMethod
("shutdownOutput", paramsClasses);
Object[] params = new Object[0];
shutdownOutput.invoke(socket, params);
} catch (Exception e) {
// Ignore, and hope everything goes right
}
}
Also, why use reflection to shutdown socket output?
Cheers.
Patrick