From: Romain Ouabdelkader <romain.ouabdelkader@gmail.com>
To: 37187@debbugs.gnu.org
Subject: bug#37187: 26.2; url-retrieve redirect lost Authorization headers
Date: Mon, 26 Aug 2019 00:08:35 +0200 [thread overview]
Message-ID: <CAJ8YToZhdbiRPrpBT=MeTZO6Eu2v5+mFL3Z10T6E7Er5bdn=rQ@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 4347 bytes --]
Hello,
I have an issue with the 'url-retrieve' function:
If the target url returns a redirect, the 'Authorization' header is not
sent on the redirect url.
Example:
List of endpoint:
http://localhost/a: 308 redirect to http://localhost/b
http://localhost/b: display all received headers
I will be using 'url-retrieve' on url 'http://localhost/a' with headers:
Authorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l
X-ExampleHeader: foo
The response shows 'X-ExampleHeader' but not 'Authorization'.
Is there a way to forward 'Authorization' aswell?
Here is a code sample:
(let ((url-request-extra-headers '(("Authorization" . "Basic
YWxhZGRpbjpvcGVuc2VzYW1l")
("X-ExampleHeader" . "foo"))))
(url-retrieve "http://localhost:5000/a" (lambda (status)
(display-buffer
(current-buffer) t))))
Server in Python with flask (pip install flask):
from flask import Flask, redirect, request, jsonify
app = Flask(__name__)
@app.route('/a')
def a():
return redirect("http://localhost:5000/b", code=308)
@app.route('/b')
def b():
return jsonify(dict(request.headers))
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000)
In GNU Emacs 26.2 (build 1, x86_64-apple-darwin18.2.0, NS appkit-1671.20
Version 10.14.3 (Build 18D109))
of 2019-04-13 built on builder10-14.porkrind.org
Windowing system distributor 'Apple', version 10.3.1671
Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
Mark set
user-error: Beginning of history; no preceding item
Contacting host: localhost:8080
Undo!
Making completion list... [2 times]
Configured using:
'configure --with-ns '--enable-locallisppath=/Library/Application
Support/Emacs/${version}/site-lisp:/Library/Application
Support/Emacs/site-lisp' --with-modules'
Configured features:
NOTIFY ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS NS MODULES THREADS
Important settings:
value of $LC_CTYPE: UTF-8
value of $LANG: en_FR.UTF-8
locale-coding-system: utf-8-unix
Major mode: Lisp Interaction
Minor modes in effect:
tooltip-mode: t
global-eldoc-mode: t
eldoc-mode: t
electric-indent-mode: t
mouse-wheel-mode: t
tool-bar-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
line-number-mode: t
transient-mark-mode: t
Load-path shadows:
None found.
Features:
(shadow sort mail-extr emacsbug message dired dired-loaddefs format-spec
rfc822 mml easymenu mml-sec epa derived epg epg-config gnus-util rmail
rmail-loaddefs mm-decode mm-bodies mm-encode mailabbrev gmm-utils
mailheader sendmail mail-utils network-stream starttls url-cache
url-http tls gnutls mail-parse rfc2231 rfc2047 rfc2045 mm-util
ietf-drums mail-prsvr url-gw nsm rmc puny seq url-auth url url-proxy
url-privacy url-expand url-methods url-history url-cookie url-domsuf
url-util url-parse auth-source cl-seq eieio byte-opt bytecomp
byte-compile cconv eieio-core cl-macs gv eieio-loaddefs cl-loaddefs
cl-lib password-cache url-vars mailcap elec-pair time-date tooltip eldoc
electric uniquify ediff-hook vc-hooks lisp-float-type mwheel term/ns-win
ns-win ucs-normalize mule-util term/common-win tool-bar dnd fontset
image regexp-opt fringe tabulated-list replace newcomment text-mode
elisp-mode lisp-mode prog-mode register page menu-bar rfn-eshadow
isearch timer select scroll-bar mouse jit-lock font-lock syntax facemenu
font-core term/tty-colors frame cl-generic cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese composite charscript charprop case-table epa-hook
jka-cmpr-hook help simple abbrev obarray minibuffer cl-preloaded nadvice
loaddefs button faces cus-face macroexp files text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote threads kqueue cocoa ns multi-tty
make-network-process emacs)
Memory information:
((conses 16 215729 11157)
(symbols 48 21206 1)
(miscs 40 48 218)
(strings 32 32992 1542)
(string-bytes 1 877912)
(vectors 16 36759)
(vector-slots 8 744932 10148)
(floats 8 51 242)
(intervals 56 379 360)
(buffers 992 13))
[-- Attachment #2: Type: text/html, Size: 5542 bytes --]
next reply other threads:[~2019-08-25 22:08 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-25 22:08 Romain Ouabdelkader [this message]
2019-09-20 20:36 ` bug#37187: 26.2; url-retrieve redirect lost Authorization headers Lars Ingebrigtsen
2019-09-21 0:01 ` Romain Ouabdelkader
2019-09-21 7:41 ` Lars Ingebrigtsen
2019-09-21 8:26 ` Romain Ouabdelkader
2019-09-21 8:40 ` Lars Ingebrigtsen
2019-09-21 9:27 ` Romain Ouabdelkader
2020-07-19 20:24 ` Lars Ingebrigtsen
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAJ8YToZhdbiRPrpBT=MeTZO6Eu2v5+mFL3Z10T6E7Er5bdn=rQ@mail.gmail.com' \
--to=romain.ouabdelkader@gmail.com \
--cc=37187@debbugs.gnu.org \
/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.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).