int http_client_request_send_payload(struct http_client_request **_req,
const unsigned char *data, size_t size)
{
+ struct http_client_request *req = *_req;
+ int ret;
+
i_assert(data != NULL);
- return http_client_request_continue_payload(_req, data, size);
+ ret = http_client_request_continue_payload(&req, data, size);
+ if (ret < 0)
+ *_req = NULL;
+ else {
+ i_assert(ret == 0);
+ i_assert(req != NULL);
+ }
+ return ret;
}
int http_client_request_finish_payload(struct http_client_request **_req)
{
- return http_client_request_continue_payload(_req, NULL, 0);
+ struct http_client_request *req = *_req;
+ int ret;
+
+ *_req = NULL;
+ ret = http_client_request_continue_payload(&req, NULL, 0);
+ i_assert(ret != 0);
+ return ret < 0 ? -1 : 0;
}
static void http_client_request_payload_input(struct http_client_request *req)
/* submits request and blocks until provided payload is sent. Multiple calls
are allowed; payload transmission is ended with
- http_client_request_finish_payload(). */
+ http_client_request_finish_payload(). If the sending fails, returns -1
+ and sets req=NULL to indicate that the request was freed, otherwise
+ returns 0 and req is unchanged. */
int http_client_request_send_payload(struct http_client_request **req,
const unsigned char *data, size_t size);
+/* Finish sending the payload. Always frees req and sets it to NULL.
+ Returns 0 on success, -1 on error. */
int http_client_request_finish_payload(struct http_client_request **req);
void http_client_request_start_tunnel(struct http_client_request *req,
*_post = NULL;
if (!post->failed) {
- if (http_client_request_finish_payload(&post->http_req) <= 0 ||
+ if (http_client_request_finish_payload(&post->http_req) < 0 ||
conn->request_status < 0) {
ret = -1;
}