Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Remove dead code from cgi.c. Attempt better error handling. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | experimental |
| Files: | files | file ages | folders |
| SHA1: |
79294bb81b45107a973efc509a7d82d9 |
| User & Date: | drh 2010-08-26 12:10:03.000 |
Context
|
2010-08-26
| ||
| 13:17 | Untested implementation of popen2() for windows. ... (Closed-Leaf check-in: 34ea1e4abb user: drh tags: experimental) | |
| 12:10 | Remove dead code from cgi.c. Attempt better error handling. ... (check-in: 79294bb81b user: drh tags: experimental) | |
| 11:27 | Fix buffering issues with ssh://. The ssh:// sync method now works with older, unmodified servers. Added the "?fossil=exe" option to URL processing. ... (check-in: af97726337 user: drh tags: experimental) | |
Changes
Changes to src/cgi.c.
| ︙ | ︙ | |||
849 850 851 852 853 854 855 |
cgi_parameter("",""); /* Force the parameters into sorted order */
for(i=0; i<nUsedQP; i++){
cgi_printf("%s = %s <br />\n",
htmlize(aParamQP[i].zName, -1), htmlize(aParamQP[i].zValue, -1));
}
}
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 849 850 851 852 853 854 855 856 857 858 859 860 861 862 |
cgi_parameter("",""); /* Force the parameters into sorted order */
for(i=0; i<nUsedQP; i++){
cgi_printf("%s = %s <br />\n",
htmlize(aParamQP[i].zName, -1), htmlize(aParamQP[i].zValue, -1));
}
}
/*
** This routine works like "printf" except that it has the
** extra formatting capabilities such as %h and %t.
*/
void cgi_printf(const char *zFormat, ...){
va_list ap;
va_start(ap,zFormat);
|
| ︙ | ︙ |
Changes to src/http.c.
| ︙ | ︙ | |||
135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
Blob hdr; /* The HTTP request header */
int closeConnection; /* True to close the connection when done */
int iLength; /* Length of the reply payload */
int rc; /* Result code */
int iHttpVersion; /* Which version of HTTP protocol server uses */
char *zLine; /* A single line of the reply header */
int i; /* Loop counter */
if( transport_open() ){
fossil_fatal(transport_errmsg());
}
/* Construct the login card and prepare the complete payload */
blob_zero(&login);
| > | 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
Blob hdr; /* The HTTP request header */
int closeConnection; /* True to close the connection when done */
int iLength; /* Length of the reply payload */
int rc; /* Result code */
int iHttpVersion; /* Which version of HTTP protocol server uses */
char *zLine; /* A single line of the reply header */
int i; /* Loop counter */
int isError = 0; /* True if the reply is an error message */
if( transport_open() ){
fossil_fatal(transport_errmsg());
}
/* Construct the login card and prepare the complete payload */
blob_zero(&login);
|
| ︙ | ︙ | |||
191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
/*
** Read and interpret the server reply
*/
closeConnection = 1;
iLength = -1;
while( (zLine = transport_receive_line())!=0 && zLine[0]!=0 ){
if( strncasecmp(zLine, "http/1.", 7)==0 ){
if( sscanf(zLine, "HTTP/1.%d %d", &iHttpVersion, &rc)!=2 ) goto write_err;
if( rc!=200 && rc!=302 ){
int ii;
for(ii=7; zLine[ii] && zLine[ii]!=' '; ii++){}
while( zLine[ii]==' ' ) ii++;
fossil_fatal("server says: %s\n", &zLine[ii]);
| > | 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
/*
** Read and interpret the server reply
*/
closeConnection = 1;
iLength = -1;
while( (zLine = transport_receive_line())!=0 && zLine[0]!=0 ){
/* printf("[%s]\n", zLine); fflush(stdout); */
if( strncasecmp(zLine, "http/1.", 7)==0 ){
if( sscanf(zLine, "HTTP/1.%d %d", &iHttpVersion, &rc)!=2 ) goto write_err;
if( rc!=200 && rc!=302 ){
int ii;
for(ii=7; zLine[ii] && zLine[ii]!=' '; ii++){}
while( zLine[ii]==' ' ) ii++;
fossil_fatal("server says: %s\n", &zLine[ii]);
|
| ︙ | ︙ | |||
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
j = strlen(zLine) - 1;
if( j>4 && strcmp(&zLine[j-4],"/xfer")==0 ) zLine[j-4] = 0;
fossil_print("redirect to %s\n", &zLine[i]);
url_parse(&zLine[i]);
transport_close();
http_exchange(pSend, pReply, useLogin);
return;
}
}
if( rc!=200 ){
fossil_fatal("\"location:\" missing from 302 redirect reply");
goto write_err;
}
/*
** Extract the reply payload that follows the header
*/
if( iLength<0 ){
fossil_fatal("server did not reply");
goto write_err;
}
blob_zero(pReply);
blob_resize(pReply, iLength);
iLength = transport_receive(blob_buffer(pReply), iLength);
blob_resize(pReply, iLength);
if( g.fHttpTrace ){
printf("HTTP RECEIVE:\n%s\n=======================\n", blob_str(pReply));
}else{
blob_uncompress(pReply, pReply);
}
/*
| > > > > > > > > > > > > > > > > | 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 |
j = strlen(zLine) - 1;
if( j>4 && strcmp(&zLine[j-4],"/xfer")==0 ) zLine[j-4] = 0;
fossil_print("redirect to %s\n", &zLine[i]);
url_parse(&zLine[i]);
transport_close();
http_exchange(pSend, pReply, useLogin);
return;
}else if( strncasecmp(zLine, "content-type: text/html", 23)==0 ){
isError = 1;
}
}
if( rc!=200 ){
fossil_fatal("\"location:\" missing from 302 redirect reply");
goto write_err;
}
/*
** Extract the reply payload that follows the header
*/
if( iLength<0 ){
fossil_fatal("server did not reply");
goto write_err;
}
blob_zero(pReply);
blob_resize(pReply, iLength);
iLength = transport_receive(blob_buffer(pReply), iLength);
blob_resize(pReply, iLength);
if( isError ){
char *z;
int i, j;
z = blob_str(pReply);
for(i=j=0; z[i]; i++, j++){
if( z[i]=='<' ){
while( z[i] && z[i]!='>' ) i++;
if( z[i]==0 ) break;
}
z[j] = z[i];
}
z[j] = 0;
fossil_fatal("server sends error: %s", z);
}
if( g.fHttpTrace ){
printf("HTTP RECEIVE:\n%s\n=======================\n", blob_str(pReply));
}else{
blob_uncompress(pReply, pReply);
}
/*
|
| ︙ | ︙ |
Changes to src/main.c.
| ︙ | ︙ | |||
914 915 916 917 918 919 920 921 |
** not select a valid repository and the --notfound option is available,
** then the server redirects (HTTP code 302) to the URL of --notfound.
*/
void cmd_http(void){
const char *zIpAddr;
const char *zNotFound;
zNotFound = find_option("notfound", 0, 1);
if( g.argc!=2 && g.argc!=3 && g.argc!=6 ){
| > | < > > | > > > > > > | 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 |
** not select a valid repository and the --notfound option is available,
** then the server redirects (HTTP code 302) to the URL of --notfound.
*/
void cmd_http(void){
const char *zIpAddr;
const char *zNotFound;
zNotFound = find_option("notfound", 0, 1);
g.cgiOutput = 1;
if( g.argc!=2 && g.argc!=3 && g.argc!=6 ){
fossil_fatal("no repository specified");
}
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;
}
find_server_repository(0);
g.zRepositoryName = enter_chroot_jail(g.zRepositoryName);
cgi_handle_http_request(zIpAddr);
process_one_web_page(zNotFound);
}
/*
** Note that the following command is used by ssh:// processing.
**
** COMMAND: test-http
** Works like the http command but gives setup permission to all users.
*/
void cmd_test_http(void){
login_set_capabilities("s");
g.httpIn = stdin;
g.httpOut = stdout;
find_server_repository(0);
g.cgiOutput = 1;
g.fullHttpReply = 1;
cgi_handle_http_request(0);
process_one_web_page(0);
}
#ifndef __MINGW32__
#if !defined(__DARWIN__) && !defined(__APPLE__)
/*
** Search for an executable on the PATH environment variable.
** Return true (1) if found and false (0) if not found.
|
| ︙ | ︙ |