Curl_read/Curl_write clarifications - replace `Curl_read()`, `Curl_write()` and `Curl_nwrite()` to 1clarify when and at what level they operate - send/recv of transfer related data is now done via `Curl_xfer_send()/Curl_xfer_recv()` which no longer has socket/socketindex as parameter. It decides on the transfer setup of `conn->sockfd` and `conn->writesockfd` on which connection filter chain to operate. - send/recv on a specific connection filter chain is done via `Curl_conn_send()/Curl_conn_recv()` which get the socket index as parameter. - rename `Curl_setup_transfer()` to `Curl_xfer_setup()` for naming consistency - clarify that the special CURLE_AGAIN handling to return `CURLE_OK` with length 0 only applies to `Curl_xfer_send()` and CURLE_AGAIN is returned by all other send() variants. SingleRequest reshuffling - move functions into request.[ch] - differentiate between reset and free - add Curl_req_done() to perform last actions - add a send `bufq` to SingleRequest for future use in keeping upload data Closes #12963
109 lines
3.1 KiB
C
109 lines
3.1 KiB
C
/***************************************************************************
|
|
* _ _ ____ _
|
|
* Project ___| | | | _ \| |
|
|
* / __| | | | |_) | |
|
|
* | (__| |_| | _ <| |___
|
|
* \___|\___/|_| \_\_____|
|
|
*
|
|
* Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
|
*
|
|
* This software is licensed as described in the file COPYING, which
|
|
* you should have received as part of this distribution. The terms
|
|
* are also available at https://curl.se/docs/copyright.html.
|
|
*
|
|
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
|
* copies of the Software, and permit persons to whom the Software is
|
|
* furnished to do so, under the terms of the COPYING file.
|
|
*
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
* KIND, either express or implied.
|
|
*
|
|
* SPDX-License-Identifier: curl
|
|
*
|
|
***************************************************************************/
|
|
|
|
#include "curl_setup.h"
|
|
|
|
#include "urldata.h"
|
|
#include "dynbuf.h"
|
|
#include "doh.h"
|
|
#include "request.h"
|
|
#include "sendf.h"
|
|
#include "url.h"
|
|
|
|
/* The last 3 #include files should be in this order */
|
|
#include "curl_printf.h"
|
|
#include "curl_memory.h"
|
|
#include "memdebug.h"
|
|
|
|
CURLcode Curl_req_init(struct SingleRequest *req)
|
|
{
|
|
memset(req, 0, sizeof(*req));
|
|
Curl_bufq_init2(&req->sendbuf, UPLOADBUFFER_DEFAULT, 1,
|
|
BUFQ_OPT_SOFT_LIMIT);
|
|
return CURLE_OK;
|
|
}
|
|
|
|
CURLcode Curl_req_start(struct SingleRequest *req,
|
|
struct Curl_easy *data)
|
|
{
|
|
req->start = Curl_now();
|
|
Curl_cw_reset(data);
|
|
return CURLE_OK;
|
|
}
|
|
|
|
CURLcode Curl_req_done(struct SingleRequest *req,
|
|
struct Curl_easy *data, bool aborted)
|
|
{
|
|
(void)req;
|
|
/* TODO: add flush handling for client output */
|
|
(void)aborted;
|
|
Curl_cw_reset(data);
|
|
return CURLE_OK;
|
|
}
|
|
|
|
void Curl_req_reset(struct SingleRequest *req, struct Curl_easy *data)
|
|
{
|
|
/* This is a bit ugly. `req->p` is a union and we assume we can
|
|
* free this safely without leaks. */
|
|
Curl_safefree(req->p.http);
|
|
Curl_safefree(req->newurl);
|
|
Curl_cw_reset(data);
|
|
|
|
Curl_bufq_reset(&req->sendbuf);
|
|
if(data->set.upload_buffer_size != req->sendbuf.chunk_size) {
|
|
Curl_bufq_free(&req->sendbuf);
|
|
Curl_bufq_init2(&req->sendbuf, data->set.upload_buffer_size, 1,
|
|
BUFQ_OPT_SOFT_LIMIT);
|
|
}
|
|
|
|
#ifndef CURL_DISABLE_DOH
|
|
if(req->doh) {
|
|
Curl_close(&req->doh->probe[0].easy);
|
|
Curl_close(&req->doh->probe[1].easy);
|
|
}
|
|
#endif
|
|
}
|
|
|
|
void Curl_req_free(struct SingleRequest *req, struct Curl_easy *data)
|
|
{
|
|
/* This is a bit ugly. `req->p` is a union and we assume we can
|
|
* free this safely without leaks. */
|
|
Curl_safefree(req->p.http);
|
|
Curl_safefree(req->newurl);
|
|
Curl_bufq_free(&req->sendbuf);
|
|
Curl_cw_reset(data);
|
|
|
|
#ifndef CURL_DISABLE_DOH
|
|
if(req->doh) {
|
|
Curl_close(&req->doh->probe[0].easy);
|
|
Curl_close(&req->doh->probe[1].easy);
|
|
Curl_dyn_free(&req->doh->probe[0].serverdoh);
|
|
Curl_dyn_free(&req->doh->probe[1].serverdoh);
|
|
curl_slist_free_all(req->doh->headers);
|
|
Curl_safefree(req->doh);
|
|
}
|
|
#endif
|
|
}
|
|
|