Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Change the --httptrace option to store both the request and the reply in separate text files. Nothing is sent to stderr any more. |
|---|---|
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
abe892304a60f9e90137c410b3587c56 |
| User & Date: | drh 2010-12-21 15:28:52.000 |
Context
|
2010-12-21
| ||
| 16:26 | Bug fix for large syncs involving delta-manifests. check-in: 8837795f53 user: drh tags: trunk | |
| 15:28 | Change the --httptrace option to store both the request and the reply in separate text files. Nothing is sent to stderr any more. check-in: abe892304a user: drh tags: trunk | |
| 14:13 | Fix a typo in the "setup_access" screen. Ticket [6a70408ccb230a20856117] check-in: 13920cd0f4 user: drh tags: trunk | |
Changes
Changes to src/http.c.
| ︙ | ︙ | |||
161 162 163 164 165 166 167 | /* Construct the HTTP request header */ http_build_header(&payload, &hdr); /* When tracing, write the transmitted HTTP message both to standard ** output and into a file. The file can then be used to drive the ** server-side like this: ** | | | < < > > > > > | 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
/* Construct the HTTP request header */
http_build_header(&payload, &hdr);
/* When tracing, write the transmitted HTTP message both to standard
** output and into a file. The file can then be used to drive the
** server-side like this:
**
** ./fossil test-http <http-request-1.txt
*/
if( g.fHttpTrace ){
static int traceCnt = 0;
char *zOutFile;
FILE *out;
traceCnt++;
zOutFile = mprintf("http-request-%d.txt", traceCnt);
out = fopen(zOutFile, "w");
if( out ){
fwrite(blob_buffer(&hdr), 1, blob_size(&hdr), out);
fwrite(blob_buffer(&payload), 1, blob_size(&payload), out);
fclose(out);
}
free(zOutFile);
zOutFile = mprintf("http-reply-%d.txt", traceCnt);
out = fopen(zOutFile, "w");
transport_log(out);
free(zOutFile);
}
/*
** Send the request to the server.
*/
transport_send(&hdr);
transport_send(&payload);
|
| ︙ | ︙ | |||
276 277 278 279 280 281 282 |
}
z[j] = z[i];
}
z[j] = 0;
fossil_fatal("server sends error: %s", z);
}
if( isCompressed ) blob_uncompress(pReply, pReply);
| < < < | 279 280 281 282 283 284 285 286 287 288 289 290 291 292 |
}
z[j] = z[i];
}
z[j] = 0;
fossil_fatal("server sends error: %s", z);
}
if( isCompressed ) blob_uncompress(pReply, pReply);
/*
** Close the connection to the server if appropriate.
**
** FIXME: There is some bug in the lower layers that prevents the
** connection from remaining open. The easiest fix for now is to
** simply close and restart the connection for each round-trip.
|
| ︙ | ︙ |
Changes to src/http_transport.c.
| ︙ | ︙ | |||
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
int nUsed ; /* Space of transportBuf[] used */
int iCursor; /* Next unread by in transportBuf[] */
i64 nSent; /* Number of bytes sent */
i64 nRcvd; /* Number of bytes received */
FILE *pFile; /* File I/O for FILE: */
char *zOutFile; /* Name of outbound file for FILE: */
char *zInFile; /* Name of inbound file for FILE: */
} transport = {
0, 0, 0, 0, 0, 0, 0
};
/*
** Information about the connection to the SSH subprocess when
** using the ssh:// sync method.
| > | 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
int nUsed ; /* Space of transportBuf[] used */
int iCursor; /* Next unread by in transportBuf[] */
i64 nSent; /* Number of bytes sent */
i64 nRcvd; /* Number of bytes received */
FILE *pFile; /* File I/O for FILE: */
char *zOutFile; /* Name of outbound file for FILE: */
char *zInFile; /* Name of inbound file for FILE: */
FILE *pLog; /* Log output here */
} transport = {
0, 0, 0, 0, 0, 0, 0
};
/*
** Information about the connection to the SSH subprocess when
** using the ssh:// sync method.
|
| ︙ | ︙ | |||
224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
void transport_close(void){
if( transport.isOpen ){
free(transport.pBuf);
transport.pBuf = 0;
transport.nAlloc = 0;
transport.nUsed = 0;
transport.iCursor = 0;
if( g.urlIsSsh ){
/* No-op */
}else if( g.urlIsHttps ){
#ifdef FOSSIL_ENABLE_SSL
ssl_close();
#endif
}else if( g.urlIsFile ){
| > > > > | 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 |
void transport_close(void){
if( transport.isOpen ){
free(transport.pBuf);
transport.pBuf = 0;
transport.nAlloc = 0;
transport.nUsed = 0;
transport.iCursor = 0;
if( transport.pLog ){
fclose(transport.pLog);
transport.pLog = 0;
}
if( g.urlIsSsh ){
/* No-op */
}else if( g.urlIsHttps ){
#ifdef FOSSIL_ENABLE_SSL
ssl_close();
#endif
}else if( g.urlIsFile ){
|
| ︙ | ︙ | |||
299 300 301 302 303 304 305 306 307 308 309 310 311 312 |
fossil_nameofexe(), g.urlName, transport.zOutFile, transport.zInFile
);
fossil_system(zCmd);
free(zCmd);
transport.pFile = fopen(transport.zInFile, "rb");
}
}
/*
** This routine is called when the inbound message has been received
** and it is time to start sending again.
*/
void transport_rewind(void){
if( g.urlIsFile ){
| > > > > > > > > > > > > | 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 |
fossil_nameofexe(), g.urlName, transport.zOutFile, transport.zInFile
);
fossil_system(zCmd);
free(zCmd);
transport.pFile = fopen(transport.zInFile, "rb");
}
}
/*
** Log all input to a file. The transport layer will take responsibility
** for closing the log file when it is done.
*/
void transport_log(FILE *pLog){
if( transport.pLog ){
fclose(transport.pLog);
transport.pLog = 0;
}
transport.pLog = pLog;
}
/*
** This routine is called when the inbound message has been received
** and it is time to start sending again.
*/
void transport_rewind(void){
if( g.urlIsFile ){
|
| ︙ | ︙ | |||
338 339 340 341 342 343 344 345 346 347 348 349 350 351 |
#endif
}else if( g.urlIsFile ){
got = fread(zBuf, 1, N, transport.pFile);
}else{
got = socket_receive(0, zBuf, N);
}
/* printf("received %d of %d bytes\n", got, N); fflush(stdout); */
return got;
}
/*
** Read N bytes of content from the wire and store in the supplied buffer.
** Return the number of bytes actually received.
*/
| > > > > | 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 |
#endif
}else if( g.urlIsFile ){
got = fread(zBuf, 1, N, transport.pFile);
}else{
got = socket_receive(0, zBuf, N);
}
/* printf("received %d of %d bytes\n", got, N); fflush(stdout); */
if( transport.pLog ){
fwrite(zBuf, 1, got, transport.pLog);
fflush(transport.pLog);
}
return got;
}
/*
** Read N bytes of content from the wire and store in the supplied buffer.
** Return the number of bytes actually received.
*/
|
| ︙ | ︙ |
Changes to src/xfer.c.
| ︙ | ︙ | |||
550 551 552 553 554 555 556 |
if( rc==0 ){
const char *zCap;
zCap = db_column_text(&q, 1);
login_set_capabilities(zCap);
g.userUid = db_column_int(&q, 2);
g.zLogin = mprintf("%b", pLogin);
g.zNonce = mprintf("%b", pNonce);
| < < < | 550 551 552 553 554 555 556 557 558 559 560 561 562 563 |
if( rc==0 ){
const char *zCap;
zCap = db_column_text(&q, 1);
login_set_capabilities(zCap);
g.userUid = db_column_int(&q, 2);
g.zLogin = mprintf("%b", pLogin);
g.zNonce = mprintf("%b", pNonce);
}
}
db_finalize(&q);
return rc;
}
/*
|
| ︙ | ︙ | |||
1280 1281 1282 1283 1284 1285 1286 |
blob_appendf(&send, "push %s %s\n", zSCode, zPCode);
nCardSent++;
}
go = 0;
/* Process the reply that came back from the server */
while( blob_line(&recv, &xfer.line) ){
| < < < < | 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 |
blob_appendf(&send, "push %s %s\n", zSCode, zPCode);
nCardSent++;
}
go = 0;
/* Process the reply that came back from the server */
while( blob_line(&recv, &xfer.line) ){
if( blob_buffer(&xfer.line)[0]=='#' ){
const char *zLine = blob_buffer(&xfer.line);
if( memcmp(zLine, "# timestamp ", 12)==0 ){
char zTime[20];
double rDiff;
sqlite3_snprintf(sizeof(zTime), zTime, "%.19s", &zLine[12]);
rDiff = db_double(9e99, "SELECT julianday('%q') - %.17g",
|
| ︙ | ︙ |