small changes:
authorbdemsky <bdemsky>
Thu, 9 Nov 2006 22:57:26 +0000 (22:57 +0000)
committerbdemsky <bdemsky>
Thu, 9 Nov 2006 22:57:26 +0000 (22:57 +0000)
1) Revert TaskExample to its original form
2) WebServerExample/Socket change:
Take it account that a long request could be split across two reads

Robust/src/Tests/TaskExample.java
Robust/src/Tests/WebServerExample.java
Robust/src/Tests/WebServerSocket.java

index 6629a4a759037fc9956adc8dc938bc6a8e1d1b73..8ad37b3409587e5e16194f35283a7fcda99b40cc 100644 (file)
@@ -14,14 +14,6 @@ class Example {
  *  system to start the computation up */
 
 task Startup(StartupObject s {initialstate}) {
-    String a = new String("hello\n");
-    String b = new String("hello\n");
-    System.printString(a);
-    System.printString(b);
-    System.printInt(b.hashCode());
-       System.printString("\n");
-    System.printInt(a.hashCode());
-
     for(int i=0;i<10;i++) {
        Example e=new Example() {needoperation};
        e.x=i;
index 09ed26d11c06ae0e5abce378ebe72c11a7fcfe1e..5d6fda0978fd750422881992299d59fef205a025 100644 (file)
@@ -23,13 +23,14 @@ task AcceptConnection(ServerSocket ss{SocketPending}) {
 task ProcessRequest(WebServerSocket web{IOPending && WebInitialize}) {
 //task ProcessRequest(WebServerSocket web{IOPending}) {
        System.printString("W> Inside ProcessRequest... \n");
-       web.clientrequest();
-       if(web.checktrans()==false)
+       if (web.clientrequest()) {
+           if(web.checktrans()==false)
                // Not special transaction , do normal filesending      
                taskexit(web {WritePending, LogPending,!WebInitialize}); //Sets the WritePending and LogPending flag true 
-       else 
+           else 
                // Invoke special inventory transaction
                taskexit(web {TransPending, LogPending,!WebInitialize});
+       }
 }
 
 //Do the WriteIO on server socket and send the requested file to Client
index 330764f69332297647fab6d297152a7dfd6d6001..411401c50bd19bd6bb37358bfe39d9de74b0f1a4 100644 (file)
@@ -7,7 +7,8 @@ public class WebServerSocket extends Socket {
        
        //Filename requested by the client 
        String filename;
-       String[] parsed; 
+        String[] parsed; 
+        String prefix;
                
        //Constructor
        public WebServerSocket(){
@@ -59,15 +60,25 @@ public class WebServerSocket extends Socket {
        }
 
        //Read the client request and extract the filename from it      
-       public int clientrequest(){
+       public boolean clientrequest(){
                byte b1[] = new byte[1024];
-               read(b1);//Read client request from web server socket
-               String clientreq = new String(b1);
-               int index = clientreq.indexOf('/');//Parse the GET client request to find filename
-               int end = clientreq.indexOf('H');
-               filename = clientreq.subString((index+1), (end-1));
-               System.printString("\n");
-               return 0;
+               int numbytes=read(b1);//Read client request from web server socket
+               String curr=(new String(b1)).subString(0, numbytes);
+               if (prefix!=null) {
+                   StringBuffer sb=new StringBuffer(prefix);
+                   sb.append(curr);
+                   curr=sb.toString();
+               }
+               prefix=curr;
+               if(prefix.indexOf("\r\n\r\n")>=0) {
+
+                   int index = prefix.indexOf('/');//Parse the GET client request to find filename
+                   int end = prefix.indexOf('H');
+                   filename = prefix.subString((index+1), (end-1));
+                   System.printString("\n");
+                   return true;
+               }
+               return false;
        }
        
        // Parse  for the prefix in the client request