summaryrefslogtreecommitdiff
path: root/http.c
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2009-04-01 16:48:24 (GMT)
committerJunio C Hamano <gitster@pobox.com>2009-04-02 20:04:07 (GMT)
commit3944ba0cb0ef5119dc9d1708c572855fca88fc43 (patch)
treeda494b01663a7405ad7c53254aa7ba5b23ee6aeb /http.c
parentdffc13166ba8950b2ddbac2406042751f96841b7 (diff)
downloadgit-3944ba0cb0ef5119dc9d1708c572855fca88fc43.zip
git-3944ba0cb0ef5119dc9d1708c572855fca88fc43.tar.gz
git-3944ba0cb0ef5119dc9d1708c572855fca88fc43.tar.bz2
Allow curl to rewind the read buffers
When using multi-pass authentication methods, the curl library may need to rewind the read buffers (depending on how much already has been fed to the server) used for providing data to HTTP PUT, POST or PROPFIND, and in order to allow the library to do so, we need to tell it how by providing either an ioctl callback or a seek callback. This patch adds an ioctl callback, which should be usable on older curl versions (since 7.12.3) than the seek callback (introduced in curl 7.18.0). Some HTTP servers (such as Apache) give an 401 error reply immediately after receiving the headers (so no data has been read from the read buffers, and thus no rewinding is needed), but other servers (such as Lighttpd) only replies after the whole request has been sent and all data has been read from the read buffers, making rewinding necessary. Signed-off-by: Martin Storsjo <martin@martin.st> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'http.c')
-rw-r--r--http.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/http.c b/http.c
index 2fc55d6..2e3d649 100644
--- a/http.c
+++ b/http.c
@@ -44,6 +44,25 @@ size_t fread_buffer(void *ptr, size_t eltsize, size_t nmemb, void *buffer_)
return size;
}
+#ifndef NO_CURL_IOCTL
+curlioerr ioctl_buffer(CURL *handle, int cmd, void *clientp)
+{
+ struct buffer *buffer = clientp;
+
+ switch (cmd) {
+ case CURLIOCMD_NOP:
+ return CURLIOE_OK;
+
+ case CURLIOCMD_RESTARTREAD:
+ buffer->posn = 0;
+ return CURLIOE_OK;
+
+ default:
+ return CURLIOE_UNKNOWNCMD;
+ }
+}
+#endif
+
size_t fwrite_buffer(const void *ptr, size_t eltsize, size_t nmemb, void *buffer_)
{
size_t size = eltsize * nmemb;