Date: Mon, 29 Jul 2013 04:32:31 GMT From: Tatsuki Makino <tatsuki_makino@hotmail.com> To: freebsd-gnats-submit@FreeBSD.org Subject: kern/180917: [patch] Add to send HTTP Accept Header for breaking through 406 to libfetch Message-ID: <201307290432.r6T4WVAg071102@oldred.freebsd.org> Resent-Message-ID: <201307290440.r6T4e098071742@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 180917 >Category: kern >Synopsis: [patch] Add to send HTTP Accept Header for breaking through 406 to libfetch >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Mon Jul 29 04:40:00 UTC 2013 >Closed-Date: >Last-Modified: >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/ >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: >Unformatted: >>> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201307290432.r6T4WVAg071102>