Fossil SCM
Add the --test option to the test-http command to make it usable interactively over an ssh link. Improve the on-line documentation for the test-http command.
Commit
9834d4dc720b5b5ef3dfea3f55173738dc8f2e056e2ea10951964bd4e3a48676
Parent
992b62fa8b85aa0…
1 file changed
+24
-4
+24
-4
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -2741,31 +2741,51 @@ | ||
| 2741 | 2741 | } while ( g.fSshClient & CGI_SSH_FOSSIL || |
| 2742 | 2742 | g.fSshClient & CGI_SSH_COMPAT ); |
| 2743 | 2743 | } |
| 2744 | 2744 | |
| 2745 | 2745 | /* |
| 2746 | -** Note that the following command is used by ssh:// processing. | |
| 2747 | -** | |
| 2748 | 2746 | ** COMMAND: test-http |
| 2749 | 2747 | ** |
| 2750 | -** Works like the [[http]] command but gives setup permission to all users. | |
| 2748 | +** Works like the [[http]] command but gives setup permission to all users, | |
| 2749 | +** or whatever permission is described by "--usercap CAP". | |
| 2750 | +** | |
| 2751 | +** This command can used for interactive debugging of web pages. For | |
| 2752 | +** example, one can put a simple HTTP request in a file like this: | |
| 2753 | +** | |
| 2754 | +** echo 'GET /timeline' >request.txt | |
| 2755 | +** | |
| 2756 | +** Then run (in a debugger) a command like this: | |
| 2757 | +** | |
| 2758 | +** fossil test-http --debug <request.txt | |
| 2759 | +** | |
| 2760 | +** This command is also used internally by the "ssh" sync protocol. Some | |
| 2761 | +** special processing to support sync happens when this command is run | |
| 2762 | +** and the SSH_CONNECTION environment variable is set. Use the --test | |
| 2763 | +** option on interactive sessions to avoid that special processing when | |
| 2764 | +** using this command interactively over SSH. A better solution would be | |
| 2765 | +** to use a different command for "ssh" sync, but we cannot do that without | |
| 2766 | +** breaking legacy. | |
| 2751 | 2767 | ** |
| 2752 | 2768 | ** Options: |
| 2769 | +** --test Do not do special "sync" processing when operating | |
| 2770 | +** over an SSH link. | |
| 2753 | 2771 | ** --th-trace Trace TH1 execution (for debugging purposes) |
| 2754 | 2772 | ** --usercap CAP User capability string (Default: "sxy") |
| 2755 | 2773 | ** |
| 2756 | 2774 | */ |
| 2757 | 2775 | void cmd_test_http(void){ |
| 2758 | 2776 | const char *zIpAddr; /* IP address of remote client */ |
| 2759 | 2777 | const char *zUserCap; |
| 2778 | + int bTest = 0; | |
| 2760 | 2779 | |
| 2761 | 2780 | Th_InitTraceLog(); |
| 2762 | 2781 | zUserCap = find_option("usercap",0,1); |
| 2763 | 2782 | if( zUserCap==0 ){ |
| 2764 | 2783 | g.useLocalauth = 1; |
| 2765 | 2784 | zUserCap = "sxy"; |
| 2766 | 2785 | } |
| 2786 | + bTest = find_option("test",0,0)!=0; | |
| 2767 | 2787 | login_set_capabilities(zUserCap, 0); |
| 2768 | 2788 | g.httpIn = stdin; |
| 2769 | 2789 | g.httpOut = stdout; |
| 2770 | 2790 | fossil_binary_mode(g.httpOut); |
| 2771 | 2791 | fossil_binary_mode(g.httpIn); |
| @@ -2773,11 +2793,11 @@ | ||
| 2773 | 2793 | find_server_repository(2, 0); |
| 2774 | 2794 | g.cgiOutput = 1; |
| 2775 | 2795 | g.fNoHttpCompress = 1; |
| 2776 | 2796 | g.fullHttpReply = 1; |
| 2777 | 2797 | g.sslNotAvailable = 1; /* Avoid attempts to redirect */ |
| 2778 | - zIpAddr = cgi_ssh_remote_addr(0); | |
| 2798 | + zIpAddr = bTest ? 0 : cgi_ssh_remote_addr(0); | |
| 2779 | 2799 | if( zIpAddr && zIpAddr[0] ){ |
| 2780 | 2800 | g.fSshClient |= CGI_SSH_CLIENT; |
| 2781 | 2801 | ssh_request_loop(zIpAddr, 0); |
| 2782 | 2802 | }else{ |
| 2783 | 2803 | cgi_set_parameter("REMOTE_ADDR", "127.0.0.1"); |
| 2784 | 2804 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -2741,31 +2741,51 @@ | |
| 2741 | } while ( g.fSshClient & CGI_SSH_FOSSIL || |
| 2742 | g.fSshClient & CGI_SSH_COMPAT ); |
| 2743 | } |
| 2744 | |
| 2745 | /* |
| 2746 | ** Note that the following command is used by ssh:// processing. |
| 2747 | ** |
| 2748 | ** COMMAND: test-http |
| 2749 | ** |
| 2750 | ** Works like the [[http]] command but gives setup permission to all users. |
| 2751 | ** |
| 2752 | ** Options: |
| 2753 | ** --th-trace Trace TH1 execution (for debugging purposes) |
| 2754 | ** --usercap CAP User capability string (Default: "sxy") |
| 2755 | ** |
| 2756 | */ |
| 2757 | void cmd_test_http(void){ |
| 2758 | const char *zIpAddr; /* IP address of remote client */ |
| 2759 | const char *zUserCap; |
| 2760 | |
| 2761 | Th_InitTraceLog(); |
| 2762 | zUserCap = find_option("usercap",0,1); |
| 2763 | if( zUserCap==0 ){ |
| 2764 | g.useLocalauth = 1; |
| 2765 | zUserCap = "sxy"; |
| 2766 | } |
| 2767 | login_set_capabilities(zUserCap, 0); |
| 2768 | g.httpIn = stdin; |
| 2769 | g.httpOut = stdout; |
| 2770 | fossil_binary_mode(g.httpOut); |
| 2771 | fossil_binary_mode(g.httpIn); |
| @@ -2773,11 +2793,11 @@ | |
| 2773 | find_server_repository(2, 0); |
| 2774 | g.cgiOutput = 1; |
| 2775 | g.fNoHttpCompress = 1; |
| 2776 | g.fullHttpReply = 1; |
| 2777 | g.sslNotAvailable = 1; /* Avoid attempts to redirect */ |
| 2778 | zIpAddr = cgi_ssh_remote_addr(0); |
| 2779 | if( zIpAddr && zIpAddr[0] ){ |
| 2780 | g.fSshClient |= CGI_SSH_CLIENT; |
| 2781 | ssh_request_loop(zIpAddr, 0); |
| 2782 | }else{ |
| 2783 | cgi_set_parameter("REMOTE_ADDR", "127.0.0.1"); |
| 2784 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -2741,31 +2741,51 @@ | |
| 2741 | } while ( g.fSshClient & CGI_SSH_FOSSIL || |
| 2742 | g.fSshClient & CGI_SSH_COMPAT ); |
| 2743 | } |
| 2744 | |
| 2745 | /* |
| 2746 | ** COMMAND: test-http |
| 2747 | ** |
| 2748 | ** Works like the [[http]] command but gives setup permission to all users, |
| 2749 | ** or whatever permission is described by "--usercap CAP". |
| 2750 | ** |
| 2751 | ** This command can used for interactive debugging of web pages. For |
| 2752 | ** example, one can put a simple HTTP request in a file like this: |
| 2753 | ** |
| 2754 | ** echo 'GET /timeline' >request.txt |
| 2755 | ** |
| 2756 | ** Then run (in a debugger) a command like this: |
| 2757 | ** |
| 2758 | ** fossil test-http --debug <request.txt |
| 2759 | ** |
| 2760 | ** This command is also used internally by the "ssh" sync protocol. Some |
| 2761 | ** special processing to support sync happens when this command is run |
| 2762 | ** and the SSH_CONNECTION environment variable is set. Use the --test |
| 2763 | ** option on interactive sessions to avoid that special processing when |
| 2764 | ** using this command interactively over SSH. A better solution would be |
| 2765 | ** to use a different command for "ssh" sync, but we cannot do that without |
| 2766 | ** breaking legacy. |
| 2767 | ** |
| 2768 | ** Options: |
| 2769 | ** --test Do not do special "sync" processing when operating |
| 2770 | ** over an SSH link. |
| 2771 | ** --th-trace Trace TH1 execution (for debugging purposes) |
| 2772 | ** --usercap CAP User capability string (Default: "sxy") |
| 2773 | ** |
| 2774 | */ |
| 2775 | void cmd_test_http(void){ |
| 2776 | const char *zIpAddr; /* IP address of remote client */ |
| 2777 | const char *zUserCap; |
| 2778 | int bTest = 0; |
| 2779 | |
| 2780 | Th_InitTraceLog(); |
| 2781 | zUserCap = find_option("usercap",0,1); |
| 2782 | if( zUserCap==0 ){ |
| 2783 | g.useLocalauth = 1; |
| 2784 | zUserCap = "sxy"; |
| 2785 | } |
| 2786 | bTest = find_option("test",0,0)!=0; |
| 2787 | login_set_capabilities(zUserCap, 0); |
| 2788 | g.httpIn = stdin; |
| 2789 | g.httpOut = stdout; |
| 2790 | fossil_binary_mode(g.httpOut); |
| 2791 | fossil_binary_mode(g.httpIn); |
| @@ -2773,11 +2793,11 @@ | |
| 2793 | find_server_repository(2, 0); |
| 2794 | g.cgiOutput = 1; |
| 2795 | g.fNoHttpCompress = 1; |
| 2796 | g.fullHttpReply = 1; |
| 2797 | g.sslNotAvailable = 1; /* Avoid attempts to redirect */ |
| 2798 | zIpAddr = bTest ? 0 : cgi_ssh_remote_addr(0); |
| 2799 | if( zIpAddr && zIpAddr[0] ){ |
| 2800 | g.fSshClient |= CGI_SSH_CLIENT; |
| 2801 | ssh_request_loop(zIpAddr, 0); |
| 2802 | }else{ |
| 2803 | cgi_set_parameter("REMOTE_ADDR", "127.0.0.1"); |
| 2804 |