From nobody@FreeBSD.org  Mon Jul 29 04:32:32 2013
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1])
	(using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by hub.freebsd.org (Postfix) with ESMTP id 2B1178FB
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 29 Jul 2013 04:32:32 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from oldred.freebsd.org (oldred.freebsd.org [8.8.178.121])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.freebsd.org (Postfix) with ESMTPS id 0808C2A49
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 29 Jul 2013 04:32:32 +0000 (UTC)
Received: from oldred.freebsd.org ([127.0.1.6])
	by oldred.freebsd.org (8.14.5/8.14.7) with ESMTP id r6T4WVh9071103
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 29 Jul 2013 04:32:31 GMT
	(envelope-from nobody@oldred.freebsd.org)
Received: (from nobody@localhost)
	by oldred.freebsd.org (8.14.5/8.14.5/Submit) id r6T4WVAg071102;
	Mon, 29 Jul 2013 04:32:31 GMT
	(envelope-from nobody)
Message-Id: <201307290432.r6T4WVAg071102@oldred.freebsd.org>
Date: Mon, 29 Jul 2013 04:32:31 GMT
From: Tatsuki Makino <tatsuki_makino@hotmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] Add to send HTTP Accept Header for breaking through 406 to libfetch 
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         180917
>Category:       kern
>Synopsis:       [libfetch] [patch] Add to send HTTP Accept Header for breaking through 406 to libfetch
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    des
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jul 29 04:40:00 UTC 2013
>Closed-Date:    Thu Oct 10 09:43:43 UTC 2013
>Last-Modified:  Thu Oct 10 09:43:43 UTC 2013
>Originator:     Tatsuki Makino
>Release:        FreeBSD 8.4-STABLE i386
>Organization:
>Environment:
FreeBSD T2.test 8.4-STABLE FreeBSD 8.4-STABLE #0 r253755M: Sun Jul 28 22:02:57 UTC 2013     root@T2.test:/usr/obj/usr/src/sys/GENERIC  i386
>Description:
Some HTTP 1.1 servers return 406 if Accept header is not sent.
>How-To-Repeat:
% fetch -o /dev/null -vv 'https://somewhere'
scheme:   [https]
user:     []
password: []
host:     [somewhere]
port:     [0]
document: [/]
---> somewhere:443
looking up somewhere
connecting to somewhere:443
SSL connection established using DHE-RSA-AES256-SHA
Certificate subject: /O=xxx/CN=somewhere/emailAddress=someone@somewhere
Certificate issuer: /O=xxx/CN=somewhere/emailAddress=someone@
requesting https://somewhere/
 >>> GET / HTTP/1.1
 >>> Host: somewhere
 >>> Referer: https://somewhere/
 >>> User-Agent: fetch libfetch/2.0
 >>> Connection: close
 >>> 
 <<< HTTP/1.1 406 Not Acceptable
 <<< Date: Mon, 29 Jul 2013 04:13:02 GMT
 <<< Server: Apache/2.2
 <<< X-Powered-By: PHP/someversion
 <<< Vary: Accept-Encoding
 <<< Content-Length: 0
 <<< Content-Type: text/html
 content length: [0]
 <<< X-Pad: avoid browser bug
 <<< Connection: close
 <<< 
 offset 0, length -1, size -1, clength 0
 fetch: https://somewhere/: Not Acceptable
 
>Fix:
This is patch for head.

Always send Accept header if patch-libfetch-accept.diff is applied.

patch-libfetch-accept_1.diff is patch that is possible to change Accept header by ENV. The name of ENV is example.

Patch attached with submission follows:

# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	patch-libfetch-accept.diff
#	patch-libfetch-accept_1.diff
#
echo x - patch-libfetch-accept.diff
sed 's/^X//' >patch-libfetch-accept.diff << '1e6674403b9e937f2325d1093dd31b4b'
XIndex: head/lib/libfetch/http.c
X===================================================================
X--- head/lib/libfetch/http.c	(revision 253755)
X+++ head/lib/libfetch/http.c	(working copy)
X@@ -1664,6 +1664,7 @@
X 		}
X 
X 		/* other headers */
X+		http_cmd(conn, "Accept: */*");
X 		if ((p = getenv("HTTP_REFERER")) != NULL && *p != '\0') {
X 			if (strcasecmp(p, "auto") == 0)
X 				http_cmd(conn, "Referer: %s://%s%s",
1e6674403b9e937f2325d1093dd31b4b
echo x - patch-libfetch-accept_1.diff
sed 's/^X//' >patch-libfetch-accept_1.diff << 'f54eb501e2954c63fbe8d7a58ad10f6a'
XIndex: head/lib/libfetch/http.c
X===================================================================
X--- head/lib/libfetch/http.c	(revision 253755)
X+++ head/lib/libfetch/http.c	(working copy)
X@@ -1664,6 +1664,12 @@
X 		}
X 
X 		/* other headers */
X+		if (((p = getenv("HTTP_ACCEPT")) != NULL ||
X+		    (p = getenv("FETCH_HTTP_ACCEPT")) != NULL) &&
X+		    *p != '\0') {
X+			http_cmd(conn, "Accept: %s", p);
X+		} else
X+			http_cmd(conn, "Accept: */*");
X 		if ((p = getenv("HTTP_REFERER")) != NULL && *p != '\0') {
X 			if (strcasecmp(p, "auto") == 0)
X 				http_cmd(conn, "Referer: %s://%s%s",
f54eb501e2954c63fbe8d7a58ad10f6a
exit



>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->des 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Tue Jul 30 02:20:11 UTC 2013 
Responsible-Changed-Why:  
Over to maintainer. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=180917 
State-Changed-From-To: open->closed 
State-Changed-By: glebius 
State-Changed-When: Thu Oct 10 09:43:32 UTC 2013 
State-Changed-Why:  
Merged to stable/9. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=180917 
>Unformatted:
