Merge branch 'bc/http-100-continue'
Issue "100 Continue" responses to help use of GSS-Negotiate authentication scheme over HTTP transport when needed. * bc/http-100-continue: remote-curl: fix large pushes with GSSAPI remote-curl: pass curl slot_results back through run_slot http: return curl's AUTHAVAIL via slot_results
This commit is contained in:
6
http.c
6
http.c
@ -761,6 +761,12 @@ void finish_active_slot(struct active_request_slot *slot)
|
|||||||
if (slot->results != NULL) {
|
if (slot->results != NULL) {
|
||||||
slot->results->curl_result = slot->curl_result;
|
slot->results->curl_result = slot->curl_result;
|
||||||
slot->results->http_code = slot->http_code;
|
slot->results->http_code = slot->http_code;
|
||||||
|
#if LIBCURL_VERSION_NUM >= 0x070a08
|
||||||
|
curl_easy_getinfo(slot->curl, CURLINFO_HTTPAUTH_AVAIL,
|
||||||
|
&slot->results->auth_avail);
|
||||||
|
#else
|
||||||
|
slot->results->auth_avail = 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Run callback if appropriate */
|
/* Run callback if appropriate */
|
||||||
|
1
http.h
1
http.h
@ -54,6 +54,7 @@
|
|||||||
struct slot_results {
|
struct slot_results {
|
||||||
CURLcode curl_result;
|
CURLcode curl_result;
|
||||||
long http_code;
|
long http_code;
|
||||||
|
long auth_avail;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct active_request_slot {
|
struct active_request_slot {
|
||||||
|
@ -394,25 +394,29 @@ static size_t rpc_in(char *ptr, size_t eltsize,
|
|||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int run_slot(struct active_request_slot *slot)
|
static int run_slot(struct active_request_slot *slot,
|
||||||
|
struct slot_results *results)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
struct slot_results results;
|
struct slot_results results_buf;
|
||||||
|
|
||||||
slot->results = &results;
|
if (!results)
|
||||||
|
results = &results_buf;
|
||||||
|
|
||||||
|
slot->results = results;
|
||||||
slot->curl_result = curl_easy_perform(slot->curl);
|
slot->curl_result = curl_easy_perform(slot->curl);
|
||||||
finish_active_slot(slot);
|
finish_active_slot(slot);
|
||||||
|
|
||||||
err = handle_curl_result(&results);
|
err = handle_curl_result(results);
|
||||||
if (err != HTTP_OK && err != HTTP_REAUTH) {
|
if (err != HTTP_OK && err != HTTP_REAUTH) {
|
||||||
error("RPC failed; result=%d, HTTP code = %ld",
|
error("RPC failed; result=%d, HTTP code = %ld",
|
||||||
results.curl_result, results.http_code);
|
results->curl_result, results->http_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int probe_rpc(struct rpc_state *rpc)
|
static int probe_rpc(struct rpc_state *rpc, struct slot_results *results)
|
||||||
{
|
{
|
||||||
struct active_request_slot *slot;
|
struct active_request_slot *slot;
|
||||||
struct curl_slist *headers = NULL;
|
struct curl_slist *headers = NULL;
|
||||||
@ -434,7 +438,7 @@ static int probe_rpc(struct rpc_state *rpc)
|
|||||||
curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_buffer);
|
curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_buffer);
|
||||||
curl_easy_setopt(slot->curl, CURLOPT_FILE, &buf);
|
curl_easy_setopt(slot->curl, CURLOPT_FILE, &buf);
|
||||||
|
|
||||||
err = run_slot(slot);
|
err = run_slot(slot, results);
|
||||||
|
|
||||||
curl_slist_free_all(headers);
|
curl_slist_free_all(headers);
|
||||||
strbuf_release(&buf);
|
strbuf_release(&buf);
|
||||||
@ -449,6 +453,7 @@ static int post_rpc(struct rpc_state *rpc)
|
|||||||
char *gzip_body = NULL;
|
char *gzip_body = NULL;
|
||||||
size_t gzip_size = 0;
|
size_t gzip_size = 0;
|
||||||
int err, large_request = 0;
|
int err, large_request = 0;
|
||||||
|
int needs_100_continue = 0;
|
||||||
|
|
||||||
/* Try to load the entire request, if we can fit it into the
|
/* Try to load the entire request, if we can fit it into the
|
||||||
* allocated buffer space we can use HTTP/1.0 and avoid the
|
* allocated buffer space we can use HTTP/1.0 and avoid the
|
||||||
@ -472,18 +477,24 @@ static int post_rpc(struct rpc_state *rpc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (large_request) {
|
if (large_request) {
|
||||||
|
struct slot_results results;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
err = probe_rpc(rpc);
|
err = probe_rpc(rpc, &results);
|
||||||
if (err == HTTP_REAUTH)
|
if (err == HTTP_REAUTH)
|
||||||
credential_fill(&http_auth);
|
credential_fill(&http_auth);
|
||||||
} while (err == HTTP_REAUTH);
|
} while (err == HTTP_REAUTH);
|
||||||
if (err != HTTP_OK)
|
if (err != HTTP_OK)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
if (results.auth_avail & CURLAUTH_GSSNEGOTIATE)
|
||||||
|
needs_100_continue = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
headers = curl_slist_append(headers, rpc->hdr_content_type);
|
headers = curl_slist_append(headers, rpc->hdr_content_type);
|
||||||
headers = curl_slist_append(headers, rpc->hdr_accept);
|
headers = curl_slist_append(headers, rpc->hdr_accept);
|
||||||
headers = curl_slist_append(headers, "Expect:");
|
headers = curl_slist_append(headers, needs_100_continue ?
|
||||||
|
"Expect: 100-continue" : "Expect:");
|
||||||
|
|
||||||
retry:
|
retry:
|
||||||
slot = get_active_slot();
|
slot = get_active_slot();
|
||||||
@ -574,7 +585,7 @@ retry:
|
|||||||
curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, rpc_in);
|
curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, rpc_in);
|
||||||
curl_easy_setopt(slot->curl, CURLOPT_FILE, rpc);
|
curl_easy_setopt(slot->curl, CURLOPT_FILE, rpc);
|
||||||
|
|
||||||
err = run_slot(slot);
|
err = run_slot(slot, NULL);
|
||||||
if (err == HTTP_REAUTH && !large_request) {
|
if (err == HTTP_REAUTH && !large_request) {
|
||||||
credential_fill(&http_auth);
|
credential_fill(&http_auth);
|
||||||
goto retry;
|
goto retry;
|
||||||
|
Reference in New Issue
Block a user