Check-in [327823e39b]
Not logged in
Overview

SHA1 Hash:327823e39bd363be157a9d32718ff7994d092220
Date: 2009-03-30 00:58:20
User: drh
Comment:Continuing work on the new HTTP transport mechanism. Make it more obvious where in the code extensions to support file: and https: belong.
Timelines: ancestors | descendants | both | trunk
Other Links: files | ZIP archive | manifest

Tags And Properties
Changes
[hide diffs]

Modified src/configure.c from [a5fbc772d1] to [d749a9aa69].

@@ -453,13 +453,10 @@
       if( zServer==0 ){
         fossil_fatal("no server specified");
       }
     }
     url_parse(zServer);
-    if( g.urlIsFile ){
-      fossil_fatal("network sync only");
-    }
     user_select();
     if( strncmp(zMethod, "push", n)==0 ){
       client_sync(0,0,0,0,mask);
     }else{
       client_sync(0,0,0,mask,0);

Modified src/http_transport.c from [e1a8cc2e75] to [e1307014ad].

@@ -37,11 +37,11 @@
   char *pBuf;     /* Buffer used to hold the reply */
   int nAlloc;     /* Space allocated for transportBuf[] */
   int nUsed ;     /* Space of transportBuf[] used */
   int iCursor;    /* Next unread by in transportBuf[] */
 } transport = {
-  0, 0, 0, 0
+  0, 0, 0, 0, 0
 };
 
 /*
 ** Return the current transport error message.
 */
@@ -59,45 +59,63 @@
 **
 ** Return the number of errors.
 */
 int transport_open(void){
   int rc = 0;
-  if( g.urlIsHttps ){
-    socket_set_errmsg("TLS is not yet implemented");
-    rc = 1;
-  }else{
-    rc = socket_open();
-    if( rc==0 ) transport.isOpen = 1;
+  if( transport.isOpen==0 ){
+    if( g.urlIsHttps ){
+      socket_set_errmsg("HTTPS: is not yet implemented");
+      rc = 1;
+    }else if( g.urlIsFile ){
+      socket_set_errmsg("FILE: is not yet implemented");
+      rc = 1;
+    }else{
+      rc = socket_open();
+      if( rc==0 ) transport.isOpen = 1;
+    }
   }
   return rc;
 }
 
 /*
 ** Close the current connection
 */
 void transport_close(void){
   if( transport.isOpen ){
-    socket_close();
     free(transport.pBuf);
     transport.pBuf = 0;
     transport.nAlloc = 0;
     transport.nUsed = 0;
     transport.iCursor = 0;
+    if( g.urlIsHttps ){
+      /* TBD */
+    }else if( g.urlIsFile ){
+      /* TBD */
+    }else{
+      socket_close();
+    }
+    transport.isOpen = 0;
   }
 }
 
 /*
 ** Send content over the wire.
 */
 void transport_send(Blob *toSend){
-  char *z = blob_buffer(toSend);
-  int n = blob_size(toSend);
-  int sent;
-  while( n>0 ){
-    sent = socket_send(0, z, n);
-    if( sent<=0 ) break;
-    n -= sent;
+  if( g.urlIsHttps ){
+    /* TBD */
+  }else if( g.urlIsFile ){
+    /* TBD */
+  }else{
+    char *z = blob_buffer(toSend);
+    int n = blob_size(toSend);
+    int sent;
+    while( n>0 ){
+      sent = socket_send(0, z, n);
+      if( sent<=0 ) break;
+      n -= sent;
+    }
   }
 }
 
 /*
 ** Read N bytes of content from the wire and store in the supplied buffer.
@@ -120,11 +138,20 @@
     N -= toMove;
     zBuf += toMove;
     nByte += toMove;
   }
   if( N>0 ){
-    int got = socket_receive(0, zBuf, N);
+    int got;
+    if( g.urlIsHttps ){
+      /* TBD */
+      got = 0;
+    }else if( g.urlIsFile ){
+      /* TBD */
+      got = 0;
+    }else{
+      got = socket_receive(0, zBuf, N);
+    }
     if( got>0 ){
       nByte += got;
     }
   }
   return nByte;

Modified src/sync.c from [5bf564823d] to [e1f5588a66].

@@ -52,13 +52,10 @@
   zUrl = db_get("last-sync-url", 0);
   if( zUrl==0 ){
     return;  /* No default server */
   }
   url_parse(zUrl);
-  if( g.urlIsFile ){
-    return;  /* Network sync only */
-  }
   if( g.urlPort!=g.urlDfltPort ){
     printf("Autosync:  %s://%s:%d%s\n",
             g.urlProtocol, g.urlName, g.urlPort, g.urlPath);
   }else{
     printf("Autosync:  %s://%s%s\n", g.urlProtocol, g.urlName, g.urlPath);
@@ -86,13 +83,10 @@
   if( zUrl==0 ){
     if( urlOptional ) exit(0);
     usage("URL");
   }
   url_parse(zUrl);
-  if( g.urlIsFile ){
-    fossil_fatal("network sync only");
-  }
   db_set("last-sync-url", zUrl, 0);
   user_select();
   if( g.argc==2 ){
     if( g.urlPort!=g.urlDfltPort ){
       printf("Server:    %s://%s:%d%s\n",

Modified src/xfer.c from [0e2cdc621f] to [0df98a4b53].

@@ -876,12 +876,10 @@
   xfer.pIn = &recv;
   xfer.pOut = &send;
   xfer.mxSend = db_get_int("max-upload", 250000);
 
   assert( pushFlag | pullFlag | cloneFlag | configRcvMask | configSendMask );
-  assert( !g.urlIsFile );          /* This only works for networking */
-
   db_begin_transaction();
   db_record_repository_filename(0);
   db_multi_exec(
     "CREATE TEMP TABLE onremote(rid INTEGER PRIMARY KEY);"
   );