;;; Code:
+(require 'cl-lib)
+(require 'puny)
(eval-when-compile
- (require 'cl-lib)
(require 'subr-x))
(defvar url-callback-arguments)
(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.
(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
(progn
(widen)
(goto-char (point-max))
- (insert "<hr>Sorry, but I do not know how to handle " type
+ (insert "<hr>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.<hr>")
;; We used to set a `status' var (declared "special") but I can't
;; 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))
(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."
(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))))))))))
"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)))