|
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 1398-1403
Link Here
|
| 1398 |
if ((conn = fetch_connect(curl->host, curl->port, af, verbose)) == NULL) |
1402 |
if ((conn = fetch_connect(curl->host, curl->port, af, verbose)) == NULL) |
| 1399 |
/* fetch_connect() has already set an error code */ |
1403 |
/* fetch_connect() has already set an error code */ |
| 1400 |
return (NULL); |
1404 |
return (NULL); |
|
|
1405 |
init_http_headerbuf(&headerbuf); |
| 1401 |
if (strcasecmp(URL->scheme, SCHEME_HTTPS) == 0 && purl) { |
1406 |
if (strcasecmp(URL->scheme, SCHEME_HTTPS) == 0 && purl) { |
| 1402 |
http_cmd(conn, "CONNECT %s:%d HTTP/1.1", |
1407 |
http_cmd(conn, "CONNECT %s:%d HTTP/1.1", |
| 1403 |
URL->host, URL->port); |
1408 |
URL->host, URL->port); |
|
Lines 1405-1414
Link Here
|
| 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 |
http_seterr(conn->err); |
| 1409 |
return (NULL); |
1414 |
goto ouch; |
| 1410 |
} |
1415 |
} |
| 1411 |
http_get_reply(conn); |
1416 |
/* Read and discard the rest of the proxy response */ |
|
|
1417 |
if (fetch_getln(conn) < 0) { |
| 1418 |
fetch_syserr(); |
| 1419 |
goto ouch; |
| 1420 |
} |
| 1421 |
do { |
| 1422 |
switch ((h = http_next_header(conn, &headerbuf, &p))) { |
| 1423 |
case hdr_syserror: |
| 1424 |
fetch_syserr(); |
| 1425 |
goto ouch; |
| 1426 |
case hdr_error: |
| 1427 |
http_seterr(HTTP_PROTOCOL_ERROR); |
| 1428 |
goto ouch; |
| 1429 |
default: |
| 1430 |
/* ignore */ ; |
| 1431 |
} |
| 1432 |
} while (h < hdr_end); |
| 1412 |
} |
1433 |
} |
| 1413 |
if (strcasecmp(URL->scheme, SCHEME_HTTPS) == 0 && |
1434 |
if (strcasecmp(URL->scheme, SCHEME_HTTPS) == 0 && |
| 1414 |
fetch_ssl(conn, URL, verbose) == -1) { |
1435 |
fetch_ssl(conn, URL, verbose) == -1) { |
|
Lines 1416-1428
Link Here
|
| 1416 |
/* grrr */ |
1437 |
/* grrr */ |
| 1417 |
errno = EAUTH; |
1438 |
errno = EAUTH; |
| 1418 |
fetch_syserr(); |
1439 |
fetch_syserr(); |
| 1419 |
return (NULL); |
1440 |
goto ouch; |
| 1420 |
} |
1441 |
} |
| 1421 |
|
1442 |
|
| 1422 |
val = 1; |
1443 |
val = 1; |
| 1423 |
setsockopt(conn->sd, IPPROTO_TCP, TCP_NOPUSH, &val, sizeof(val)); |
1444 |
setsockopt(conn->sd, IPPROTO_TCP, TCP_NOPUSH, &val, sizeof(val)); |
| 1424 |
|
1445 |
|
|
|
1446 |
clean_http_headerbuf(&headerbuf); |
| 1425 |
return (conn); |
1447 |
return (conn); |
|
|
1448 |
ouch: |
| 1449 |
serrno = errno; |
| 1450 |
clean_http_headerbuf(&headerbuf); |
| 1451 |
fetch_close(conn); |
| 1452 |
errno = serrno; |
| 1453 |
return (NULL); |
| 1426 |
} |
1454 |
} |
| 1427 |
|
1455 |
|
| 1428 |
static struct url * |
1456 |
static struct url * |