[Webfunds-commits] java/webfunds/sox BasicAgent.java HttpAgent.java

Ian Grigg iang@cypherpunks.ai
Thu, 31 Aug 2000 10:17:15 -0400 (AST)


iang        00/08/31 10:17:15

  Modified:    webfunds/sox BasicAgent.java HttpAgent.java
  Log:
  On seeing a HTTP "500 Internal Error" HttpAgent will now set the
  LATER number, and BasicAgent will pass that one up as a SOXLaterEx.
  This occurs when the SOX Server is down, and the HTTP frontend knows it.

Revision  Changes    Path
1.14      +8 -4      java/webfunds/sox/BasicAgent.java

Index: BasicAgent.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/sox/BasicAgent.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- BasicAgent.java	2000/08/20 02:59:29	1.13
+++ BasicAgent.java	2000/08/31 14:17:14	1.14
@@ -1,5 +1,5 @@
 /*
- * $Id: BasicAgent.java,v 1.13 2000/08/20 02:59:29 gelderen Exp $
+ * $Id: BasicAgent.java,v 1.14 2000/08/31 14:17:14 iang Exp $
  *
  * Copyright (c) Systemics Ltd 1995-1999 on behalf of
  * the WebFunds Development Team.  All Rights Reserved.
@@ -65,11 +65,15 @@
         try {
             replyData = comms.request(brp.encode());
         } catch (SOXAgentConnectException ex) {
-            throw new SOXLaterException("SOXAconnectE: " + ex);
+            throw new SOXLaterException(ex.getNumber(), "SOXAconnectE: " + ex);
         } catch (SOXAgentReplyException ex) {
-            throw new SOXPacketException("SOXAreplyE: " + ex);
+            int errno = ex.getNumber();
+            if (errno == SOXException.LATER_DOWN)
+                throw new SOXLaterException(errno, "SOXAreplyE: " + ex);
+            else
+                throw new SOXPacketException(errno, "SOXAreplyE: " + ex);
         } catch (SOXAgentURLException ex) {
-            throw new SOXIssuerException("SOXurlE: " + ex);
+            throw new SOXIssuerException(ex.getNumber(), "SOXurlE: " + ex);
         }
         BasicReplyPacket reply = new BasicReplyPacket(replyData);
 



1.20      +12 -4     java/webfunds/sox/HttpAgent.java

Index: HttpAgent.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/sox/HttpAgent.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- HttpAgent.java	2000/07/10 17:37:55	1.19
+++ HttpAgent.java	2000/08/31 14:17:14	1.20
@@ -1,5 +1,5 @@
 /*
- * $Id: HttpAgent.java,v 1.19 2000/07/10 17:37:55 iang Exp $
+ * $Id: HttpAgent.java,v 1.20 2000/08/31 14:17:14 iang Exp $
  *
  * Copyright (c) Systemics Ltd 1995-1999 on behalf of
  * the WebFunds Development Team.  All Rights Reserved.
@@ -141,6 +141,7 @@
 
 
 
+
     /**
      * Send a Http request and await the reply.
      * This method uses the low level socket code to get more control.
@@ -239,6 +240,7 @@
         boolean ok = true;
         int length = -1;
         String errors = "";
+        int errno = SOXException.UNKNOWN;
 
         //
         // On the reads, the timeout will cause a
@@ -251,7 +253,7 @@
                 line = getLine(is).trim();
             } catch (IOException ex) {
                 logmsg(ex.getMessage());
-                throw new SOXAgentReplyException("headers: " + ex);
+                throw new SOXAgentReplyException(errno, "headers: " + ex);
             }
 
             if ("".equals(line))
@@ -259,7 +261,13 @@
 
             if (line.startsWith(serverVersion))
             {
-                if (line.indexOf(" 200 ") < 0)
+                if (line.indexOf(" 500 Internal Error") >= 0)
+                {
+                    ok = false;
+                    errno = SOXException.LATER_DOWN;
+                    errors += "  later, down: <<" + line + ">>";
+                }
+                else if (line.indexOf(" 200 ") < 0)
                 {
                     ok = false;
                     errors += "  failed: <<" + line + ">>";
@@ -303,7 +311,7 @@
             if (i > 0)
                 s += "\n" + new String(errorHtml, 0, i) + "\n";
             logmsg(s);
-            throw new SOXAgentReplyException(s);
+            throw new SOXAgentReplyException(errno, s);
         }
 
         if (length <= 0)