|
Lines 1376-1383
Link Here
|
| 1376 |
{ |
1376 |
{ |
| 1377 |
struct url *curl; |
1377 |
struct url *curl; |
| 1378 |
conn_t *conn; |
1378 |
conn_t *conn; |
|
|
1379 |
hdr_t h; |
| 1380 |
http_headerbuf_t headerbuf; |
| 1381 |
const char *p; |
| 1379 |
int verbose; |
1382 |
int verbose; |
| 1380 |
int af, val; |
1383 |
int af, val; |
|
|
1384 |
int serrno; |
| 1381 |
|
1385 |
|
| 1382 |
#ifdef INET6 |
1386 |
#ifdef INET6 |
| 1383 |
af = AF_UNSPEC; |
1387 |
af = AF_UNSPEC; |
|
Lines 1395-1400
Link Here
|
| 1395 |
|
1399 |
|
| 1396 |
curl = (purl != NULL) ? purl : URL; |
1400 |
curl = (purl != NULL) ? purl : URL; |
| 1397 |
|
1401 |
|
|
|
1402 |
init_http_headerbuf(&headerbuf); |
| 1398 |
if ((conn = fetch_connect(curl->host, curl->port, af, verbose)) == NULL) |
1403 |
if ((conn = fetch_connect(curl->host, curl->port, af, verbose)) == NULL) |
| 1399 |
/* fetch_connect() has already set an error code */ |
1404 |
/* fetch_connect() has already set an error code */ |
| 1400 |
return (NULL); |
1405 |
return (NULL); |
|
Lines 1404-1414
Link Here
|
| 1404 |
http_cmd(conn, "Host: %s:%d", |
1409 |
http_cmd(conn, "Host: %s:%d", |
| 1405 |
URL->host, URL->port); |
1410 |
URL->host, URL->port); |
| 1406 |
http_cmd(conn, ""); |
1411 |
http_cmd(conn, ""); |
| 1407 |
if (http_get_reply(conn) != HTTP_OK) { |
1412 |
if (http_get_reply(conn) != HTTP_OK) |
| 1408 |
fetch_close(conn); |
1413 |
goto ouch; |
| 1409 |
return (NULL); |
1414 |
/* Read and discard the rest of the proxy response */ |
|
|
1415 |
if (fetch_getln(conn) < 0) { |
| 1416 |
fetch_syserr(); |
| 1417 |
goto ouch; |
| 1410 |
} |
1418 |
} |
| 1411 |
http_get_reply(conn); |
1419 |
do { |
|
|
1420 |
switch ((h = http_next_header(conn, &headerbuf, &p))) { |
| 1421 |
case hdr_syserror: |
| 1422 |
fetch_syserr(); |
| 1423 |
goto ouch; |
| 1424 |
case hdr_error: |
| 1425 |
http_seterr(HTTP_PROTOCOL_ERROR); |
| 1426 |
goto ouch; |
| 1427 |
default: |
| 1428 |
/* ignore */ ; |
| 1429 |
} |
| 1430 |
} while (h < hdr_end); |
| 1412 |
} |
1431 |
} |
| 1413 |
if (strcasecmp(URL->scheme, SCHEME_HTTPS) == 0 && |
1432 |
if (strcasecmp(URL->scheme, SCHEME_HTTPS) == 0 && |
| 1414 |
fetch_ssl(conn, URL, verbose) == -1) { |
1433 |
fetch_ssl(conn, URL, verbose) == -1) { |
|
Lines 1416-1428
Link Here
|
| 1416 |
/* grrr */ |
1435 |
/* grrr */ |
| 1417 |
errno = EAUTH; |
1436 |
errno = EAUTH; |
| 1418 |
fetch_syserr(); |
1437 |
fetch_syserr(); |
| 1419 |
return (NULL); |
1438 |
goto ouch; |
| 1420 |
} |
1439 |
} |
| 1421 |
|
1440 |
|
| 1422 |
val = 1; |
1441 |
val = 1; |
| 1423 |
setsockopt(conn->sd, IPPROTO_TCP, TCP_NOPUSH, &val, sizeof(val)); |
1442 |
setsockopt(conn->sd, IPPROTO_TCP, TCP_NOPUSH, &val, sizeof(val)); |
| 1424 |
|
1443 |
|
|
|
1444 |
clean_http_headerbuf(&headerbuf); |
| 1425 |
return (conn); |
1445 |
return (conn); |
|
|
1446 |
ouch: |
| 1447 |
serrno = errno; |
| 1448 |
clean_http_headerbuf(&headerbuf); |
| 1449 |
fetch_close(conn); |
| 1450 |
errno = serrno; |
| 1451 |
return (NULL); |
| 1426 |
} |
1452 |
} |
| 1427 |
|
1453 |
|
| 1428 |
static struct url * |
1454 |
static struct url * |