111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
-
-
|
** the complete payload (including the login card) already compressed.
*/
static void http_build_header(
Blob *pPayload, /* the payload that will be sent */
Blob *pHdr, /* construct the header here */
const char *zAltMimetype /* Alternative mimetype */
){
int i;
int nPayload = pPayload ? blob_size(pPayload) : 0;
blob_zero(pHdr);
i = strlen(g.url.path);
blob_appendf(pHdr, "%s %s HTTP/1.0\r\n",
nPayload>0 ? "POST" : "GET", g.url.path);
if( g.url.proxyAuth ){
blob_appendf(pHdr, "Proxy-Authorization: %s\r\n", g.url.proxyAuth);
}
if( g.zHttpAuth && g.zHttpAuth[0] ){
const char *zCredentials = g.zHttpAuth;
|
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
|
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
|
+
+
+
+
+
+
|
closeConnection = 1;
}else if( c=='k' || c=='K' ){
closeConnection = 0;
}
}else if( ( rc==301 || rc==302 || rc==307 || rc==308 ) &&
fossil_strnicmp(zLine, "location:", 9)==0 ){
int i, j;
int wasHttps;
if ( --maxRedirect == 0){
fossil_warning("redirect limit exceeded");
goto write_err;
}
for(i=9; zLine[i] && zLine[i]==' '; i++){}
if( zLine[i]==0 ){
fossil_warning("malformed redirect: %s", zLine);
goto write_err;
}
j = strlen(zLine) - 1;
while( j>4 && fossil_strcmp(&zLine[j-4],"/xfer")==0 ){
j -= 4;
zLine[j] = 0;
}
if( (mHttpFlags & HTTP_QUIET)==0 ){
fossil_print("redirect with status %d to %s\n", rc, &zLine[i]);
}
wasHttps = g.url.isHttps;
url_parse(&zLine[i], 0);
if( wasHttps && !g.url.isHttps ){
fossil_warning("cannot redirect from HTTPS to HTTP");
goto write_err;
}
transport_close(&g.url);
transport_global_shutdown(&g.url);
fSeenHttpAuth = 0;
if( g.zHttpAuth ) free(g.zHttpAuth);
g.zHttpAuth = get_httpauth();
if( rc==301 || rc==308 ) url_remember();
return http_exchange(pSend, pReply, mHttpFlags,
|