From d0a9bbb912630fee4fe7d29b6ec0655142f42fad Mon Sep 17 00:00:00 2001 From: Juan RP Date: Tue, 18 Mar 2014 14:08:40 +0100 Subject: [PATCH] Fix #34 (make libfetch always add "Accept: */*" in the HTTP header). --- NEWS | 6 ++++++ lib/fetch/http.c | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/NEWS b/NEWS index adf84f55..5a141011 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,11 @@ xbps-0.34 (???): + * Fix #34 (xbps-uhelper fetch fails to download files from https://alioth.debian.org). + The issue is that this HTTP server returns 406 (Not Acceptable) when the HTTP + header does not contain the "Accept" field (see + https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=712261 for more info). + Our libfetch code now always adds "Accept: */*" in the HTTP headers. + * Added some debugging in error paths when performing a transaction. * Fixed an issue where in a transaction a package with wrong version was being diff --git a/lib/fetch/http.c b/lib/fetch/http.c index d405a6a4..adc55902 100644 --- a/lib/fetch/http.c +++ b/lib/fetch/http.c @@ -939,8 +939,16 @@ http_request(struct url *URL, const char *op, struct url_stat *us, http_cmd(conn, "User-Agent: %s\r\n", p); else http_cmd(conn, "User-Agent: %s\r\n", _LIBFETCH_VER); + + /* + * Some servers returns 406 (Not Acceptable) if the Accept field is not + * provided by the user agent, such example is http://alioth.debian.org. + */ + http_cmd(conn, "Accept: */*\r\n"); + if (url->offset > 0) http_cmd(conn, "Range: bytes=%lld-\r\n", (long long)url->offset); + http_cmd(conn, "\r\n"); /*