70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
+
+
-
+
|
char *zTop; /* Parent directory of zPath */
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 */
Th_Interp *interp; /* The TH1 interpreter */
FILE *httpIn; /* Accept HTTP input from here */
FILE *httpOut; /* Send HTTP output here */
int *aCommitFile;
int *aCommitFile; /* Array of files to be committed */
int urlIsFile; /* True if a "file:" url */
char *urlName; /* Hostname for http: or filename for file: */
char *urlHostname; /* The HOST: parameter on http headers */
int urlPort; /* TCP port number for http: */
char *urlPath; /* Pathname for http: */
char *urlUser; /* User id for http: */
|
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
|
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
|
+
+
+
+
+
+
+
-
+
+
+
-
+
+
+
+
+
+
-
+
|
cgi_panic("Unable to find or open the project repository");
}
cgi_init();
process_one_web_page();
}
/*
** undocumented format:
**
** fossil http REPOSITORY INFILE OUTFILE IPADDR
**
** The argv==6 form is used by the win32 server only.
**
** COMMAND: http
**
** Usage: %fossil http REPOSITORY
**
** Handle a single HTTP request appearing on stdin. The resulting webpage
** 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;
if( g.argc!=2 && g.argc!=3 ){
if( g.argc!=2 && g.argc!=3 && g.argc!=6 ){
cgi_panic("no repository specified");
}
g.cgiPanic = 1;
g.httpIn = stdin;
g.httpOut = stdout;
if( g.argc==3 ){
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();
cgi_handle_http_request(zIpAddr);
process_one_web_page();
}
/*
** COMMAND: test-http
** Works like the http command but gives setup permission to all users.
*/
|
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
|
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
|
+
+
-
+
+
+
+
+
-
+
+
+
+
+
|
iPort = 8080;
}
if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?");
if( g.argc==2 ){
db_must_be_within_tree();
db_close();
}
#ifndef __MINGW32__
/* Unix implementation */
cgi_http_server(iPort);
if( cgi_http_server(iPort) ){
fossil_fatal("unable to listen on TCP socket %d", iPort);
}
g.httpIn = stdin;
g.httpOut = stdout;
if( g.fHttpTrace ){
fprintf(stderr, "====== SERVER pid %d =======\n", getpid());
}
g.cgiPanic = 1;
if( g.argc==2 ){
db_must_be_within_tree();
}else{
db_open_repository(g.argv[2]);
}
cgi_handle_http_request();
cgi_handle_http_request(0);
process_one_web_page();
#else
/* Win32 implementation */
win32_http_server(iPort);
#endif
}
|