summaryrefslogtreecommitdiffstats
path: root/http.c
diff options
context:
space:
mode:
authorMasaya Suzuki <masayasuzuki@google.com>2019-01-10 11:33:46 -0800
committerJunio C Hamano <gitster@pobox.com>2019-01-10 15:00:56 -0800
commit8dd2e88a923bd24775182f0a507c993e06a0aacb (patch)
treef8d4f1fce3c16f57eed0006496f5fff2b13de0a0 /http.c
parent5d826e972970a784bd7a7bdf587512510097b8c7 (diff)
downloadgit-8dd2e88a923bd24775182f0a507c993e06a0aacb.tar.gz
git-8dd2e88a923bd24775182f0a507c993e06a0aacb.tar.xz
http: support file handles for HTTP_KEEP_ERROR
HTTP_KEEP_ERROR makes it easy to debug HTTP transport errors. In order to make HTTP_KEEP_ERROR enabled for all requests, file handles need to be supported. Signed-off-by: Masaya Suzuki <masayasuzuki@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'http.c')
-rw-r--r--http.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/http.c b/http.c
index eacc2a75e..ab4279a1c 100644
--- a/http.c
+++ b/http.c
@@ -1952,16 +1952,26 @@ static int http_request_reauth(const char *url,
/*
* If we are using KEEP_ERROR, the previous request may have
* put cruft into our output stream; we should clear it out before
- * making our next request. We only know how to do this for
- * the strbuf case, but that is enough to satisfy current callers.
+ * making our next request.
*/
if (options && options->keep_error) {
switch (target) {
case HTTP_REQUEST_STRBUF:
strbuf_reset(result);
break;
+ case HTTP_REQUEST_FILE:
+ if (fflush(result)) {
+ error_errno("unable to flush a file");
+ return HTTP_START_FAILED;
+ }
+ rewind(result);
+ if (ftruncate(fileno(result), 0) < 0) {
+ error_errno("unable to truncate a file");
+ return HTTP_START_FAILED;
+ }
+ break;
default:
- BUG("HTTP_KEEP_ERROR is only supported with strbufs");
+ BUG("Unknown http_request target");
}
}