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
|
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 http <http-trace-1.txt
** ./fossil test-http <http-request-1.txt
*/
if( g.fHttpTrace ){
static int traceCnt = 0;
char *zOutFile;
FILE *out;
traceCnt++;
zOutFile = mprintf("http-trace-%d.txt", traceCnt);
zOutFile = mprintf("http-request-%d.txt", traceCnt);
printf("HTTP SEND: (%s)\n%s%s=======================\n",
zOutFile, blob_str(&hdr), blob_str(&payload));
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
283
284
285
286
287
288
289
290
291
292
|
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);
if( g.fHttpTrace ){
/*printf("HTTP RECEIVE:\n%s\n=======================\n",blob_str(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.
|