X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/95a2cb24b0697558e6629460d8bc693b394f0138..9f2f14a0725211b13a744573344636b57b9c98b9:/lisp/url/url-http.el diff --git a/lisp/url/url-http.el b/lisp/url/url-http.el index d766952ebf..36cc2f32bb 100644 --- a/lisp/url/url-http.el +++ b/lisp/url/url-http.el @@ -25,8 +25,9 @@ ;;; Code: +(require 'cl-lib) +(require 'puny) (eval-when-compile - (require 'cl-lib) (require 'subr-x)) (defvar url-callback-arguments) @@ -135,17 +136,6 @@ request.") (507 insufficient-storage "Insufficient storage")) "The HTTP return codes and their text.") -(defcustom url-user-agent (format "User-Agent: %sURL/%s\r\n" - (if url-package-name - (concat url-package-name "/" - url-package-version " ") - "") url-version) - "User Agent used by the URL package." - :type '(choice (string :tag "A static User-Agent string") - (function :tag "Call a function to get the User-Agent string")) - :version "25.1" - :group 'url) - ;(eval-when-compile ;; These are all macros so that they are hidden from external sight ;; when the file is byte-compiled. @@ -318,8 +308,9 @@ request.") (url-scheme-get-property (url-type url-http-target-url) 'default-port)) (format - "Host: %s:%d\r\n" host (url-port url-http-target-url)) - (format "Host: %s\r\n" host)) + "Host: %s:%d\r\n" (puny-encode-domain host) + (url-port url-http-target-url)) + (format "Host: %s\r\n" (puny-encode-domain host))) ;; Who its from (if url-personal-mail-address (concat @@ -431,7 +422,7 @@ Return the number of characters removed." (progn (widen) (goto-char (point-max)) - (insert "
Sorry, but I do not know how to handle " type + (insert "
Sorry, but I do not know how to handle " (or type auth url "") " authentication. If you'd like to write it," " please use M-x report-emacs-bug RET.
") ;; We used to set a `status' var (declared "special") but I can't @@ -485,6 +476,8 @@ work correctly." ) ) +(declare-function gnutls-peer-status "gnutls.c" (proc)) + (defun url-http-parse-headers () "Parse and handle HTTP specific headers. Return t if and only if the current buffer is still active and @@ -644,6 +637,12 @@ should be shown to the user." ;; compute the redirection relative to the URL of the proxy. (setq redirect-uri (url-expand-file-name redirect-uri url-http-target-url))) + ;; Do not automatically include an authorization header in the + ;; redirect. If needed it will be regenerated by the relevant + ;; auth scheme when the new request happens. + (setq url-http-extra-headers + (cl-remove "Authorization" + url-http-extra-headers :key 'car :test 'equal)) (let ((url-request-method url-http-method) (url-request-data url-http-data) (url-request-extra-headers url-http-extra-headers)) @@ -978,7 +977,7 @@ the callback to be triggered." (url-http-activate-callback))))) (defun url-http-chunked-encoding-after-change-function (st nd length) - "Function used when dealing with 'chunked' encoding. + "Function used when dealing with chunked encoding. Cannot give a sophisticated percentage, but we need a different function to look for the special 0-length chunk that signifies the end of the document." @@ -1059,7 +1058,7 @@ the end of the document." (when (looking-at "\r?\n") (url-http-debug "Removing terminator of last chunk") (delete-region (match-beginning 0) (match-end 0))) - (if (re-search-forward "^\r*$" nil t) + (if (re-search-forward "^\r?\n" nil t) (url-http-debug "Saw end of trailers...")) (if (url-http-parse-headers) (url-http-activate-callback)))))))))) @@ -1198,17 +1197,20 @@ the end of the document." "Retrieve URL via HTTP asynchronously. URL must be a parsed URL. See `url-generic-parse-url' for details. -When retrieval is completed, execute the function CALLBACK, passing it -an updated value of CBARGS as arguments. The first element in CBARGS -should be a plist describing what has happened so far during the -request, as described in the docstring of `url-retrieve' (if in -doubt, specify nil). +When retrieval is completed, execute the function CALLBACK, +passing it an updated value of CBARGS as arguments. The first +element in CBARGS should be a plist describing what has happened +so far during the request, as described in the docstring of +`url-retrieve' (if in doubt, specify nil). The current buffer +then CALLBACK is executed is the retrieval buffer. Optional arg RETRY-BUFFER, if non-nil, specifies the buffer of a previous `url-http' call, which is being re-attempted. Optional arg GATEWAY-METHOD specifies the gateway to be used, -overriding the value of `url-gateway-method'." +overriding the value of `url-gateway-method'. + +The return value of this function is the retrieval buffer." (cl-check-type url vector "Need a pre-parsed URL.") (let* ((host (url-host (or url-using-proxy url))) (port (url-port (or url-using-proxy url)))