diff options
author | Stef Walter <stef@memberwebs.com> | 2006-10-20 15:43:20 +0000 |
---|---|---|
committer | Stef Walter <stef@memberwebs.com> | 2006-10-20 15:43:20 +0000 |
commit | 87da3655492bb009f84f2e101a08dfb3a0a35592 (patch) | |
tree | 225e9e084127f3bae4d5ec853f2a8109bcb50c2c /java/src/com | |
parent | 8135e62aa423f7ae08b2cbfcccf4a634ae0cb122 (diff) |
- Reconnect to httpauthd when that daemon has been restarted.
Diffstat (limited to 'java/src/com')
-rw-r--r-- | java/src/com/memberwebs/httpauth/BaseHttpAuthenticator.java | 30 | ||||
-rw-r--r-- | java/src/com/memberwebs/httpauth/HttpAuthConnection.java | 3 |
2 files changed, 16 insertions, 17 deletions
diff --git a/java/src/com/memberwebs/httpauth/BaseHttpAuthenticator.java b/java/src/com/memberwebs/httpauth/BaseHttpAuthenticator.java index 8dd15f1..140beec 100644 --- a/java/src/com/memberwebs/httpauth/BaseHttpAuthenticator.java +++ b/java/src/com/memberwebs/httpauth/BaseHttpAuthenticator.java @@ -85,8 +85,18 @@ public abstract class BaseHttpAuthenticator conn.sendLine("AUTH " + args); sendHeaders(conn, request, authtypes); - // If above was successful get out of this retry loop - break; + rsp = conn.readResponse(200); + copyHeaders(conn, response, authtypes); + + if(rsp.ccode != 200) + { + setResponseResult(response, rsp.ccode); + return null; + } + else + { + return rsp.details; + } } catch(SocketException e) { @@ -94,7 +104,7 @@ public abstract class BaseHttpAuthenticator conn.close(); // Stupid hack but java doesn't let us do any better just now - if(!e.getMessage().startsWith("Broken pipe")) + if(!e.getMessage().toLowerCase().startsWith("broken pipe")) throw new HttpAuthException("error communicating with httpauthd", e); } @@ -106,18 +116,6 @@ public abstract class BaseHttpAuthenticator m_source.doneWithConnection(conn); } - rsp = conn.readResponse(200); - copyHeaders(conn, response, authtypes); - - if(rsp.ccode != 200) - { - setResponseResult(response, rsp.ccode); - return null; - } - else - { - return rsp.details; - } } catch(IOException e) { @@ -127,7 +125,7 @@ public abstract class BaseHttpAuthenticator conn.close(); } catch(IOException ex) - { } + { } throw new HttpAuthException("error communicating with httpauthd", e); } diff --git a/java/src/com/memberwebs/httpauth/HttpAuthConnection.java b/java/src/com/memberwebs/httpauth/HttpAuthConnection.java index e29aaae..b26dc09 100644 --- a/java/src/com/memberwebs/httpauth/HttpAuthConnection.java +++ b/java/src/com/memberwebs/httpauth/HttpAuthConnection.java @@ -45,6 +45,7 @@ import java.io.OutputStreamWriter; import java.io.Writer; import java.net.InetSocketAddress; import java.net.Socket; +import java.net.SocketException; import java.util.HashMap; import java.util.Iterator; import java.util.Map; @@ -256,7 +257,7 @@ public class HttpAuthConnection String line = readLine(); if(line == null) - throw new IOException("unexpected end of data from httpauthd"); + throw new SocketException("Broken Pipe: unexpected end of data from httpauthd"); String word = parseWord(line); line = line.substring(word.length()); |