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.

drh 2021-09-08 12:21 trunk
Commit 9834d4dc720b5b5ef3dfea3f55173738dc8f2e056e2ea10951964bd4e3a48676
1 file changed +24 -4
+24 -4
--- src/main.c
+++ src/main.c
@@ -2741,31 +2741,51 @@
27412741
} while ( g.fSshClient & CGI_SSH_FOSSIL ||
27422742
g.fSshClient & CGI_SSH_COMPAT );
27432743
}
27442744
27452745
/*
2746
-** Note that the following command is used by ssh:// processing.
2747
-**
27482746
** COMMAND: test-http
27492747
**
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.
27512767
**
27522768
** Options:
2769
+** --test Do not do special "sync" processing when operating
2770
+** over an SSH link.
27532771
** --th-trace Trace TH1 execution (for debugging purposes)
27542772
** --usercap CAP User capability string (Default: "sxy")
27552773
**
27562774
*/
27572775
void cmd_test_http(void){
27582776
const char *zIpAddr; /* IP address of remote client */
27592777
const char *zUserCap;
2778
+ int bTest = 0;
27602779
27612780
Th_InitTraceLog();
27622781
zUserCap = find_option("usercap",0,1);
27632782
if( zUserCap==0 ){
27642783
g.useLocalauth = 1;
27652784
zUserCap = "sxy";
27662785
}
2786
+ bTest = find_option("test",0,0)!=0;
27672787
login_set_capabilities(zUserCap, 0);
27682788
g.httpIn = stdin;
27692789
g.httpOut = stdout;
27702790
fossil_binary_mode(g.httpOut);
27712791
fossil_binary_mode(g.httpIn);
@@ -2773,11 +2793,11 @@
27732793
find_server_repository(2, 0);
27742794
g.cgiOutput = 1;
27752795
g.fNoHttpCompress = 1;
27762796
g.fullHttpReply = 1;
27772797
g.sslNotAvailable = 1; /* Avoid attempts to redirect */
2778
- zIpAddr = cgi_ssh_remote_addr(0);
2798
+ zIpAddr = bTest ? 0 : cgi_ssh_remote_addr(0);
27792799
if( zIpAddr && zIpAddr[0] ){
27802800
g.fSshClient |= CGI_SSH_CLIENT;
27812801
ssh_request_loop(zIpAddr, 0);
27822802
}else{
27832803
cgi_set_parameter("REMOTE_ADDR", "127.0.0.1");
27842804
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button