From 87da3655492bb009f84f2e101a08dfb3a0a35592 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Fri, 20 Oct 2006 15:43:20 +0000 Subject: - Reconnect to httpauthd when that daemon has been restarted. --- .../memberwebs/httpauth/BaseHttpAuthenticator.java | 30 ++++++++++------------ .../memberwebs/httpauth/HttpAuthConnection.java | 3 ++- 2 files changed, 16 insertions(+), 17 deletions(-) (limited to 'java') 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()); -- cgit v1.2.3