Differences From:
File
src/http_transport.c
part of check-in
[7a2c37063a]
- merge trunk into creole branch
by
bob on
2009-09-22 07:49:39.
Also file
src/http_transport.c
part of check-in
[0eb08b860c]
- Change more system() calls into portable_system() in an effort to fix
path quoting problems on windows.
by
drh on
2009-09-16 21:29:18.
[view]
To:
File
src/http_transport.c
part of check-in
[16f6fd904a]
- Add SSL support.
by
dmitry on
2009-11-09 15:32:32.
[view]
@@ -50,8 +50,13 @@
/*
** Return the current transport error message.
*/
const char *transport_errmsg(void){
+ #ifdef FOSSIL_ENABLE_SSL
+ if( g.urlIsHttps ){
+ return ssl_errmsg();
+ }
+ #endif
return socket_errmsg();
}
/*
@@ -80,10 +85,15 @@
int transport_open(void){
int rc = 0;
if( transport.isOpen==0 ){
if( g.urlIsHttps ){
- socket_set_errmsg("HTTPS: is not yet implemented");
+ #ifdef FOSSIL_ENABLE_SSL
+ rc = ssl_open();
+ if( rc==0 ) transport.isOpen = 1;
+ #else
+ socket_set_errmsg("HTTPS: Fossil has been compiled without SSL support");
rc = 1;
+ #endif
}else if( g.urlIsFile ){
sqlite3_uint64 iRandId;
sqlite3_randomness(sizeof(iRandId), &iRandId);
transport.zOutFile = mprintf("%s-%llu-out.http",
@@ -113,9 +123,11 @@
transport.nAlloc = 0;
transport.nUsed = 0;
transport.iCursor = 0;
if( g.urlIsHttps ){
- /* TBD */
+ #ifdef FOSSIL_ENABLE_SSL
+ ssl_close();
+ #endif
}else if( g.urlIsFile ){
if( transport.pFile ){
fclose(transport.pFile);
transport.pFile = 0;
@@ -138,9 +150,17 @@
char *z = blob_buffer(toSend);
int n = blob_size(toSend);
transport.nSent += n;
if( g.urlIsHttps ){
- /* TBD */
+ #ifdef FOSSIL_ENABLE_SSL
+ int sent;
+ while( n>0 ){
+ sent = ssl_send(0, z, n);
+ /* printf("Sent %d of %d bytes\n", sent, n); fflush(stdout); */
+ if( sent<=0 ) break;
+ n -= sent;
+ }
+ #endif
}else if( g.urlIsFile ){
fwrite(z, 1, n, transport.pFile);
}else{
int sent;
@@ -205,10 +225,14 @@
}
if( N>0 ){
int got;
if( g.urlIsHttps ){
- /* TBD */
+ #ifdef FOSSIL_ENABLE_SSL
+ got = ssl_receive(0, zBuf, N);
+ /* printf("received %d of %d bytes\n", got, N); fflush(stdout); */
+ #else
got = 0;
+ #endif
}else if( g.urlIsFile ){
got = fread(zBuf, 1, N, transport.pFile);
}else{
got = socket_receive(0, zBuf, N);
@@ -293,5 +317,15 @@
i++;
}
/* printf("Got line: [%s]\n", &transport.pBuf[iStart]); */
return &transport.pBuf[iStart];
+}
+
+void *transport_global_shutdown(void){
+ if( g.urlIsHttps ){
+ #ifdef FOSSIL_ENABLE_SSL
+ ssl_global_shutdown();
+ #endif
+ }else{
+ socket_global_shutdown();
+ }
}