Git development
 help / color / mirror / Atom feed
From: Junio C Hamano <junkio@cox.net>
To: Marco Costalba <mcostalba@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: Cloning from sites with 404 overridden
Date: Sun, 19 Mar 2006 15:21:34 -0800	[thread overview]
Message-ID: <7vmzfmm35t.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: e5bfff550603191340u466d3551t8a95c3808eb977c1@mail.gmail.com

"Marco Costalba" <mcostalba@gmail.com> writes:

> Finally accessing the missing object with a browser
>
> http://digilander.libero.it/mcostalba/
> scm/qgit.git/objects/8d/ea03519e75f47da91108330dde3043defddd60
>
> gives a pre-canned (in italian) 'Sorry page not found' stuff.
>
> So I really think the site "HTTP/1.0 200 OK" response it's a fake.
> Perhaps security related to avoid sniffing (just a guess because I have
> absolutely zero competence in security related things).

I think you are just rephrasing what I said.  From the HTTP
protocol perspective, you _do_ have that 8d/3a0351 thing on that
server, because you do not correctly say "No we donot have it"
using 404 response.

Your inability to produce 404 is a different matter -- often the
hosting server is not under your control.  But that does not
change the fact that the repository observed by your clients is
"broken".  That is why a workaround flag like I suggested may be
needed for such a setup.

This is totally untested, but maybe something like this?

---
diff --git a/http-fetch.c b/http-fetch.c
index 7de818b..d523798 100644
--- a/http-fetch.c
+++ b/http-fetch.c
@@ -8,6 +8,7 @@
 #define RANGE_HEADER_SIZE 30
 
 static int got_alternates = -1;
+static int unreliable_404 = 0;
 
 static struct curl_slist *no_pragma_header;
 
@@ -822,12 +823,18 @@ static int fetch_object(struct alt_base 
 		close(obj_req->local); obj_req->local = -1;
 	}
 
+	
+
 	if (obj_req->state == ABORTED) {
 		ret = error("Request for %s aborted", hex);
-	} else if (obj_req->curl_result != CURLE_OK &&
-		   obj_req->http_code != 416) {
+	} else if ((obj_req->curl_result != CURLE_OK &&
+		    obj_req->http_code != 416)  ||
+		   (unreliable_404 &&
+		    obj_req->curl_result == CURLE_OK &&
+		    obj_req->zret != Z_STREAM_END)) {
 		if (obj_req->http_code == 404 ||
-		    obj_req->curl_result == CURLE_FILE_COULDNT_READ_FILE)
+		    obj_req->curl_result == CURLE_FILE_COULDNT_READ_FILE ||
+		    unreliable_404)
 			ret = -1; /* Be silent, it is probably in a pack. */
 		else
 			ret = error("%s (curl_result = %d, http_code = %ld, sha1 = %s)",
@@ -966,6 +973,8 @@ int main(int argc, char **argv)
 			arg++;
 		} else if (!strcmp(argv[arg], "--recover")) {
 			get_recover = 1;
+		} else if (!strcmp(argv[arg], "--unreliable-404")) {
+			unreliable_404 = 1;
 		}
 		arg++;
 	}

  reply	other threads:[~2006-03-19 23:21 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-19 10:52 Cloning from sites with 404 overridden Marco Costalba
2006-03-19 13:25 ` Paolo Ciarrocchi
2006-03-19 14:04   ` Marco Costalba
2006-03-19 19:37     ` Junio C Hamano
2006-03-19 21:40       ` Marco Costalba
2006-03-19 23:21         ` Junio C Hamano [this message]
2006-03-20  6:31           ` Marco Costalba
2006-03-20  8:44             ` Junio C Hamano
2006-03-20 12:17               ` Marco Costalba
2006-03-20 18:29       ` Lukas Sandström
2006-03-20 19:43         ` Petr Baudis
2006-03-20 19:54         ` Nick Hengeveld
2006-03-19 19:47     ` Junio C Hamano
2006-03-19 21:31       ` Petr Baudis
2006-03-19 21:43         ` Petr Baudis
2006-03-19 21:45         ` Marco Costalba
2006-03-20  4:32       ` Randal L. Schwartz
  -- strict thread matches above, loose matches on Subject: below --
2006-03-22  2:59 linux
2006-03-22  3:12 ` Shawn Pearce
2006-03-22  4:13   ` Linus Torvalds
2006-03-22  6:06 ` Marco Costalba
2006-03-22  6:47   ` Junio C Hamano
2006-03-22 13:36 ` Andreas Ericsson
2006-03-24 17:29   ` Mark Wooding
2006-03-24 17:52     ` Junio C Hamano
2006-03-24 17:53     ` Linus Torvalds
2006-03-24 18:16     ` Morten Welinder
2006-03-24 18:40     ` Andreas Ericsson
2006-03-22 17:22 ` Nick Hengeveld
2006-03-22 18:36   ` Nick Hengeveld
2006-03-22 19:05     ` Junio C Hamano
2006-03-22 19:22       ` Junio C Hamano
2006-03-23 18:43         ` Nick Hengeveld
2006-03-23 20:45           ` Junio C Hamano
2006-03-22 21:24       ` Radoslaw Szkodzinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vmzfmm35t.fsf@assigned-by-dhcp.cox.net \
    --to=junkio@cox.net \
    --cc=git@vger.kernel.org \
    --cc=mcostalba@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox