5
5
* | (__| |_| | _ <| |___
6
6
* \___|\___/|_| \_\_____|
8
* Copyright (C) 1998 - 2005, Daniel Stenberg, <daniel@haxx.se>, et al.
8
* Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
10
10
* This software is licensed as described in the file COPYING, which
11
11
* you should have received as part of this distribution. The terms
18
18
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19
19
* KIND, either express or implied.
21
* $Id: http.c,v 1.275 2005/10/20 20:07:33 bagder Exp $
21
* $Id: http.c,v 1.282 2006-05-05 22:14:40 bagder Exp $
22
22
***************************************************************************/
846
845
CURLcode add_buffer_send(send_buffer *in,
847
846
struct connectdata *conn,
848
long *bytes_written) /* add the number of sent
847
long *bytes_written, /* add the number of sent
849
848
bytes to this counter */
855
855
struct HTTP *http = conn->proto.http;
857
curl_socket_t sockfd = conn->sock[FIRSTSOCKET];
857
curl_socket_t sockfd;
859
curlassert(socketindex <= SECONDARYSOCKET);
861
sockfd = conn->sock[socketindex];
859
863
/* The looping below is required since we use non-blocking sockets, but due
860
864
to the circumstances we will just loop and try again and again etc */
1166
1170
if(CURLE_OK == result)
1167
1171
/* Now send off the request */
1168
1172
result = add_buffer_send(req_buffer, conn,
1169
&data->info.request_size);
1173
&data->info.request_size, sockindex);
1172
1176
failf(data, "Failed sending CONNECT to proxy");
1356
1360
* after the connect has occured, can we start talking SSL
1359
if(conn->bits.tunnel_proxy) {
1363
if(conn->bits.tunnel_proxy && conn->bits.httpproxy) {
1361
1365
/* either SSL over proxy, or explicitly asked for */
1362
1366
result = Curl_proxyCONNECT(conn, FIRSTSOCKET,
1369
if(conn->protocol & PROT_HTTPS) {
1370
/* perform SSL initialization for this socket */
1371
result = Curl_ssl_connect(conn, FIRSTSOCKET);
1376
1373
if(!data->state.this_is_a_follow) {
1377
1374
/* this is not a followed location, get the original host name */
1378
1375
if (data->state.first_host)
1382
1379
data->state.first_host = strdup(conn->host.name);
1382
if(conn->protocol & PROT_HTTPS) {
1383
/* perform SSL initialization */
1384
if(data->state.used_interface == Curl_if_multi) {
1385
result = Curl_https_connecting(conn, done);
1391
result = Curl_ssl_connect(conn, FIRSTSOCKET);
1404
CURLcode Curl_https_connecting(struct connectdata *conn, bool *done)
1407
curlassert(conn->protocol & PROT_HTTPS);
1409
/* perform SSL initialization for this socket */
1410
result = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET, done);
1418
/* This function is OpenSSL-specific. It should be made to query the generic
1419
SSL layer instead. */
1420
int Curl_https_getsock(struct connectdata *conn,
1421
curl_socket_t *socks,
1424
if (conn->protocol & PROT_HTTPS) {
1425
struct ssl_connect_data *connssl = &conn->ssl[FIRSTSOCKET];
1428
return GETSOCK_BLANK;
1430
if (connssl->connecting_state == ssl_connect_2_writing) {
1432
socks[0] = conn->sock[FIRSTSOCKET];
1433
return GETSOCK_WRITESOCK(0);
1435
else if (connssl->connecting_state == ssl_connect_2_reading) {
1437
socks[0] = conn->sock[FIRSTSOCKET];
1438
return GETSOCK_READSOCK(0);
1445
int Curl_https_getsock(struct connectdata *conn,
1446
curl_socket_t *socks,
1452
return GETSOCK_BLANK;
1391
1458
* Curl_http_done() gets called from Curl_done() after a single HTTP request
2034
2101
result = add_buffer_send(req_buffer, conn,
2035
&data->info.request_size);
2102
&data->info.request_size, FIRSTSOCKET);
2037
2104
failf(data, "Failed sending POST request");
2098
2165
/* fire away the whole request to the server */
2099
2166
result = add_buffer_send(req_buffer, conn,
2100
&data->info.request_size);
2167
&data->info.request_size, FIRSTSOCKET);
2102
2169
failf(data, "Failed sending POST request");
2142
2209
/* this sends the buffer and frees all the buffer resources */
2143
2210
result = add_buffer_send(req_buffer, conn,
2144
&data->info.request_size);
2211
&data->info.request_size, FIRSTSOCKET);
2146
2213
failf(data, "Failed sending PUT request");
2264
2331
/* issue the request */
2265
2332
result = add_buffer_send(req_buffer, conn,
2266
&data->info.request_size);
2333
&data->info.request_size, FIRSTSOCKET);
2269
2336
failf(data, "Failed sending HTTP POST request");
2281
2348
/* issue the request */
2282
2349
result = add_buffer_send(req_buffer, conn,
2283
&data->info.request_size);
2350
&data->info.request_size, FIRSTSOCKET);
2286
2353
failf(data, "Failed sending HTTP request");