| | @@ -71,10 +71,11 @@ |
| 71 | 71 | const char *zContentType; /* The content type of the input HTTP request */ |
| 72 | 72 | int iErrPriority; /* Priority of current error message */ |
| 73 | 73 | char *zErrMsg; /* Text of an error message */ |
| 74 | 74 | Blob cgiIn; /* Input to an xfer www method */ |
| 75 | 75 | int cgiPanic; /* Write error messages to CGI */ |
| 76 | + int fullHttpReply; /* True for full HTTP reply. False for CGI reply */ |
| 76 | 77 | Th_Interp *interp; /* The TH1 interpreter */ |
| 77 | 78 | FILE *httpIn; /* Accept HTTP input from here */ |
| 78 | 79 | FILE *httpOut; /* Send HTTP output here */ |
| 79 | 80 | int xlinkClusterOnly; /* Set when cloning. Only process clusters */ |
| 80 | 81 | |
| | @@ -244,11 +245,10 @@ |
| 244 | 245 | z = vmprintf(zFormat, ap); |
| 245 | 246 | va_end(ap); |
| 246 | 247 | if( g.cgiPanic && once ){ |
| 247 | 248 | once = 0; |
| 248 | 249 | cgi_printf("<p><font color=\"red\">%h</font></p>", z); |
| 249 | | - style_footer(); |
| 250 | 250 | cgi_reply(); |
| 251 | 251 | }else{ |
| 252 | 252 | fprintf(stderr, "%s: %s\n", g.argv[0], z); |
| 253 | 253 | } |
| 254 | 254 | db_force_rollback(); |
| | @@ -261,11 +261,10 @@ |
| 261 | 261 | z = vmprintf(zFormat, ap); |
| 262 | 262 | va_end(ap); |
| 263 | 263 | if( g.cgiPanic ){ |
| 264 | 264 | g.cgiPanic = 0; |
| 265 | 265 | cgi_printf("<p><font color=\"red\">%h</font></p>", z); |
| 266 | | - style_footer(); |
| 267 | 266 | cgi_reply(); |
| 268 | 267 | }else{ |
| 269 | 268 | fprintf(stderr, "%s: %s\n", g.argv[0], z); |
| 270 | 269 | } |
| 271 | 270 | db_force_rollback(); |
| | @@ -635,24 +634,27 @@ |
| 635 | 634 | ** is delivered on stdout. This method is used to launch an HTTP request |
| 636 | 635 | ** handler from inetd, for example. The argument is the name of the |
| 637 | 636 | ** repository. |
| 638 | 637 | */ |
| 639 | 638 | void cmd_http(void){ |
| 640 | | - const char *zIpAddr = 0; |
| 639 | + const char *zIpAddr; |
| 641 | 640 | if( g.argc!=2 && g.argc!=3 && g.argc!=6 ){ |
| 642 | 641 | cgi_panic("no repository specified"); |
| 643 | 642 | } |
| 644 | 643 | g.cgiPanic = 1; |
| 645 | | - g.httpIn = stdin; |
| 646 | | - g.httpOut = stdout; |
| 644 | + g.fullHttpReply = 1; |
| 645 | + if( g.argc==6 ){ |
| 646 | + g.httpIn = fopen(g.argv[3], "rb"); |
| 647 | + g.httpOut = fopen(g.argv[4], "wb"); |
| 648 | + zIpAddr = g.argv[5]; |
| 649 | + }else{ |
| 650 | + g.httpIn = stdin; |
| 651 | + g.httpOut = stdout; |
| 652 | + zIpAddr = 0; |
| 653 | + } |
| 647 | 654 | if( g.argc>=3 ){ |
| 648 | 655 | db_open_repository(g.argv[2]); |
| 649 | | - if( g.argc==6 ){ |
| 650 | | - g.httpIn = fopen(g.argv[3], "rb"); |
| 651 | | - g.httpOut = fopen(g.argv[4], "wb"); |
| 652 | | - zIpAddr = g.argv[5]; |
| 653 | | - } |
| 654 | 656 | }else{ |
| 655 | 657 | db_must_be_within_tree(); |
| 656 | 658 | } |
| 657 | 659 | cgi_handle_http_request(zIpAddr); |
| 658 | 660 | process_one_web_page(); |
| | @@ -696,12 +698,14 @@ |
| 696 | 698 | iPort = 8080; |
| 697 | 699 | } |
| 698 | 700 | if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?"); |
| 699 | 701 | if( g.argc==2 ){ |
| 700 | 702 | db_must_be_within_tree(); |
| 701 | | - db_close(); |
| 703 | + }else{ |
| 704 | + db_open_repository(g.argv[2]); |
| 702 | 705 | } |
| 706 | + db_close(); |
| 703 | 707 | #ifndef __MINGW32__ |
| 704 | 708 | /* Unix implementation */ |
| 705 | 709 | if( g.argv[1][0]=='u' ){ |
| 706 | 710 | #if !defined(__DARWIN__) && !defined(__APPLE__) |
| 707 | 711 | zBrowser = db_get("web-browser", "firefox"); |
| 708 | 712 | |