void http_client_request_resubmit(struct http_client_request *req) { i_assert(!req->payload_wait); http_client_request_debug(req, "Resubmitting request"); /* rewind payload stream */ if (req->payload_input != NULL && req->payload_size > 0) { if (req->payload_input->v_offset != req->payload_offset && !req->payload_input->seekable) { http_client_request_error(&req, HTTP_CLIENT_REQUEST_ERROR_ABORTED, "Resubmission failed: Cannot resend payload; stream is not seekable"); return; } else { i_stream_seek(req->payload_input, req->payload_offset); } } /* drop payload output stream from previous attempt */ if (req->payload_output != NULL) o_stream_unref(&req->payload_output); req->conn = NULL; req->peer = NULL; req->state = HTTP_REQUEST_STATE_QUEUED; http_client_host_submit_request(req->host, req); }
static void http_client_request_do_submit(struct http_client_request *req) { struct http_client *client = req->client; struct http_client_host *host; const struct http_url *proxy_url = client->set.proxy_url; const char *authority, *target; i_assert(req->state == HTTP_REQUEST_STATE_NEW); authority = http_url_create_authority(&req->origin_url); if (req->connect_tunnel) { /* connect requests require authority form for request target */ target = authority; } else { /* absolute target url */ target = t_strconcat (http_url_create_host(&req->origin_url), req->target, NULL); } /* determine what host to contact to submit this request */ if (proxy_url != NULL) { if (req->origin_url.have_ssl && !client->set.no_ssl_tunnel && !req->connect_tunnel) { req->host_url = &req->origin_url; /* tunnel to origin server */ req->ssl_tunnel = TRUE; } else { req->host_url = proxy_url; /* proxy server */ } } else { req->host_url = &req->origin_url; /* origin server */ } /* use submission date if no date is set explicitly */ if (req->date == (time_t)-1) req->date = ioloop_time; /* prepare value for Host header */ req->authority = p_strdup(req->pool, authority); /* debug label */ req->label = p_strdup_printf(req->pool, "[%s %s]", req->method, target); /* update request target */ if (req->connect_tunnel || proxy_url != NULL) req->target = p_strdup(req->pool, target); if (proxy_url == NULL) { /* if we don't have a proxy, CONNECT requests are handled by creating the requested connection directly */ req->connect_direct = req->connect_tunnel; if (req->connect_direct) req->urgent = TRUE; } host = http_client_host_get(req->client, req->host_url); req->state = HTTP_REQUEST_STATE_QUEUED; http_client_host_submit_request(host, req); }