diff options
| author | Junio C Hamano <gitster@pobox.com> | 2010-01-10 08:53:04 -0800 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2010-01-10 08:53:04 -0800 |
| commit | 637afcf4e07616d1dd15d33f56c6b72f90f39821 (patch) | |
| tree | 50a740f63784f4d7420a431bb73a922cc4e02409 /remote-curl.c | |
| parent | 0b4ae29f0328fb8c270030abad132e8f50e05381 (diff) | |
| parent | 525ecd26c6cc8d1dc0c6190d8266e5d30b06da51 (diff) | |
| download | git-637afcf4e07616d1dd15d33f56c6b72f90f39821.tar.gz | |
Merge branch 'tr/http-updates'
* tr/http-updates:
Remove http.authAny
Allow curl to rewind the RPC read buffer
Add an option for using any HTTP authentication scheme, not only basic
http: maintain curl sessions
Diffstat (limited to 'remote-curl.c')
| -rw-r--r-- | remote-curl.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/remote-curl.c b/remote-curl.c index a331bae6c8..28b2a316d3 100644 --- a/remote-curl.c +++ b/remote-curl.c @@ -290,6 +290,7 @@ struct rpc_state { int out; struct strbuf result; unsigned gzip_request : 1; + unsigned initial_buffer : 1; }; static size_t rpc_out(void *ptr, size_t eltsize, @@ -300,6 +301,7 @@ static size_t rpc_out(void *ptr, size_t eltsize, size_t avail = rpc->len - rpc->pos; if (!avail) { + rpc->initial_buffer = 0; avail = packet_read_line(rpc->out, rpc->buf, rpc->alloc); if (!avail) return 0; @@ -314,6 +316,29 @@ static size_t rpc_out(void *ptr, size_t eltsize, return avail; } +#ifndef NO_CURL_IOCTL +curlioerr rpc_ioctl(CURL *handle, int cmd, void *clientp) +{ + struct rpc_state *rpc = clientp; + + switch (cmd) { + case CURLIOCMD_NOP: + return CURLIOE_OK; + + case CURLIOCMD_RESTARTREAD: + if (rpc->initial_buffer) { + rpc->pos = 0; + return CURLIOE_OK; + } + fprintf(stderr, "Unable to rewind rpc post data - try increasing http.postBuffer\n"); + return CURLIOE_FAILRESTART; + + default: + return CURLIOE_UNKNOWNCMD; + } +} +#endif + static size_t rpc_in(const void *ptr, size_t eltsize, size_t nmemb, void *buffer_) { @@ -370,8 +395,13 @@ static int post_rpc(struct rpc_state *rpc) */ headers = curl_slist_append(headers, "Expect: 100-continue"); headers = curl_slist_append(headers, "Transfer-Encoding: chunked"); + rpc->initial_buffer = 1; curl_easy_setopt(slot->curl, CURLOPT_READFUNCTION, rpc_out); curl_easy_setopt(slot->curl, CURLOPT_INFILE, rpc); +#ifndef NO_CURL_IOCTL + curl_easy_setopt(slot->curl, CURLOPT_IOCTLFUNCTION, rpc_ioctl); + curl_easy_setopt(slot->curl, CURLOPT_IOCTLDATA, rpc); +#endif if (options.verbosity > 1) { fprintf(stderr, "POST %s (chunked)\n", rpc->service_name); fflush(stderr); |
