Overview
SHA1 Hash: | dcc48662f838417842f182972517e785e2f3d444 |
---|---|
Date: | 2008-06-08 15:45:36 |
User: | drh |
Comment: | Better error messages when trying to run "fossil ui" with an invalid or unaccessible repository. |
Timelines: | ancestors | descendants | both | trunk |
Other Links: | files | ZIP archive | manifest |
Tags And Properties
- branch=trunk inherited from [a28c83647d]
- sym-trunk inherited from [a28c83647d]
Changes
[hide diffs]Modified src/cgi.c from [51ee933035] to [5d10f16d56].
@@ -153,11 +153,10 @@ */ static char *zContentType = "text/html"; /* Content type of the reply */ static char *zReplyStatus = "OK"; /* Reply status description */ static int iReplyStatus = 200; /* Reply status code */ static Blob extraHeader = BLOB_INITIALIZER; /* Extra header text */ -static int fullHttpReply = 0; /* True for a full-blown HTTP header */ /* ** Set the reply content type */ void cgi_set_content_type(const char *zType){ @@ -285,11 +284,11 @@ iReplyStatus = 304; zReplyStatus = "Not Modified"; } #endif - if( fullHttpReply ){ + if( g.fullHttpReply ){ fprintf(g.httpOut, "HTTP/1.0 %d %s\r\n", iReplyStatus, zReplyStatus); fprintf(g.httpOut, "Date: %s\r\n", cgi_rfc822_datestamp(time(0))); fprintf(g.httpOut, "Connection: close\r\n"); }else{ fprintf(g.httpOut, "Status: %d %s\r\n", iReplyStatus, zReplyStatus); @@ -1091,11 +1090,11 @@ int i; struct sockaddr_in remoteName; size_t size = sizeof(struct sockaddr_in); char zLine[2000]; /* A single line of input. */ - fullHttpReply = 1; + g.fullHttpReply = 1; if( fgets(zLine, sizeof(zLine),g.httpIn)==0 ){ malformed_request(); } zToken = extract_token(zLine, &z); if( zToken==0 ){
Modified src/main.c from [96c79d2faa] to [be97bf56d4].
@@ -71,10 +71,11 @@ const char *zContentType; /* The content type of the input HTTP request */ int iErrPriority; /* Priority of current error message */ char *zErrMsg; /* Text of an error message */ Blob cgiIn; /* Input to an xfer www method */ int cgiPanic; /* Write error messages to CGI */ + int fullHttpReply; /* True for full HTTP reply. False for CGI reply */ Th_Interp *interp; /* The TH1 interpreter */ FILE *httpIn; /* Accept HTTP input from here */ FILE *httpOut; /* Send HTTP output here */ int xlinkClusterOnly; /* Set when cloning. Only process clusters */ @@ -244,11 +245,10 @@ z = vmprintf(zFormat, ap); va_end(ap); if( g.cgiPanic && once ){ once = 0; cgi_printf("<p><font color=\"red\">%h</font></p>", z); - style_footer(); cgi_reply(); }else{ fprintf(stderr, "%s: %s\n", g.argv[0], z); } db_force_rollback(); @@ -261,11 +261,10 @@ z = vmprintf(zFormat, ap); va_end(ap); if( g.cgiPanic ){ g.cgiPanic = 0; cgi_printf("<p><font color=\"red\">%h</font></p>", z); - style_footer(); cgi_reply(); }else{ fprintf(stderr, "%s: %s\n", g.argv[0], z); } db_force_rollback(); @@ -635,24 +634,27 @@ ** is delivered on stdout. This method is used to launch an HTTP request ** handler from inetd, for example. The argument is the name of the ** repository. */ void cmd_http(void){ - const char *zIpAddr = 0; + const char *zIpAddr; if( g.argc!=2 && g.argc!=3 && g.argc!=6 ){ cgi_panic("no repository specified"); } g.cgiPanic = 1; - g.httpIn = stdin; - g.httpOut = stdout; + g.fullHttpReply = 1; + if( g.argc==6 ){ + g.httpIn = fopen(g.argv[3], "rb"); + g.httpOut = fopen(g.argv[4], "wb"); + zIpAddr = g.argv[5]; + }else{ + g.httpIn = stdin; + g.httpOut = stdout; + zIpAddr = 0; + } if( g.argc>=3 ){ db_open_repository(g.argv[2]); - if( g.argc==6 ){ - g.httpIn = fopen(g.argv[3], "rb"); - g.httpOut = fopen(g.argv[4], "wb"); - zIpAddr = g.argv[5]; - } }else{ db_must_be_within_tree(); } cgi_handle_http_request(zIpAddr); process_one_web_page(); @@ -696,12 +698,14 @@ iPort = 8080; } if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?"); if( g.argc==2 ){ db_must_be_within_tree(); - db_close(); + }else{ + db_open_repository(g.argv[2]); } + db_close(); #ifndef __MINGW32__ /* Unix implementation */ if( g.argv[1][0]=='u' ){ #if !defined(__DARWIN__) && !defined(__APPLE__) zBrowser = db_get("web-browser", "firefox");
Modified src/style.c from [850e5f952e] to [d4b64100f2].
@@ -41,10 +41,16 @@ const char *zLink; } aSubmenu[30]; static int nSubmenu = 0; /* +** Remember that the header has been generated. The footer is omitted +** if an error occurs before the header. +*/ +static int headerHasBeenGenerated = 0; + +/* ** Add a new element to the submenu */ void style_submenu_element( const char *zLabel, const char *zTitle, @@ -98,17 +104,20 @@ } Th_Render(zHeader); Th_Unstore("title"); /* Avoid collisions with ticket field names */ cgi_destination(CGI_BODY); g.cgiPanic = 1; + headerHasBeenGenerated = 1; } /* ** Draw the footer at the bottom of the page. */ void style_footer(void){ const char *zFooter; + + if( !headerHasBeenGenerated ) return; /* Go back and put the submenu at the top of the page. We delay the ** creation of the submenu until the end so that we can add elements ** to the submenu while generating page text. */