* lisp/emacs-lisp/package.el: Use tar-mode rather than tar executable.
[bpt/emacs.git] / lisp / url / url-http.el
index 0b5ecc7..33fc572 100644 (file)
@@ -1,6 +1,6 @@
 ;;; url-http.el --- HTTP retrieval routines
 
-;; Copyright (C) 1999, 2001, 2004-201 Free Software Foundation, Inc.
+;; Copyright (C) 1999, 2001, 2004-2013 Free Software Foundation, Inc.
 
 ;; Author: Bill Perry <wmperry@gnu.org>
 ;; Keywords: comm, data, processes
@@ -215,17 +215,11 @@ request.")
          (and (listp url-privacy-level)
               (memq 'agent url-privacy-level)))
       ""
-    (format "User-Agent: %sURL/%s%s\r\n"
+    (format "User-Agent: %sURL/%s\r\n"
            (if url-package-name
                (concat url-package-name "/" url-package-version " ")
              "")
-           url-version
-           (cond
-            ((and url-os-type url-system-type)
-             (concat " (" url-os-type "; " url-system-type ")"))
-            ((or url-os-type url-system-type)
-             (concat " (" (or url-system-type url-os-type) ")"))
-            (t "")))))
+           url-version)))
 
 (defun url-http-create-request (&optional ref-url)
   "Create an HTTP request for `url-http-target-url', referred to by REF-URL."
@@ -239,7 +233,7 @@ request.")
                         nil
                       (let ((url-basic-auth-storage
                              'url-http-proxy-basic-auth-storage))
-                        (url-get-authentication url-http-target-url nil 'any nil))))
+                        (url-get-authentication url-http-proxy nil 'any nil))))
         (real-fname (url-filename url-http-target-url))
         (host (url-host url-http-target-url))
         (auth (if (cdr-safe (assoc "Authorization" url-http-extra-headers))
@@ -508,13 +502,10 @@ should be shown to the user."
        (class nil)
        (success nil)
        ;; other status symbols: jewelry and luxury cars
-       (status-symbol (cadr (assq url-http-response-status url-http-codes)))
-       ;; The filename part of a URL could be in remote file syntax,
-       ;; see Bug#6717 for an example.  We disable file name
-       ;; handlers, therefore.
-       (file-name-handler-alist nil))
+       (status-symbol (cadr (assq url-http-response-status url-http-codes))))
     (setq class (/ url-http-response-status 100))
-    (url-http-debug "Parsed HTTP headers: class=%d status=%d" class url-http-response-status)
+    (url-http-debug "Parsed HTTP headers: class=%d status=%d"
+                    class url-http-response-status)
     (when (url-use-cookies url-http-target-url)
       (url-http-handle-cookies))
 
@@ -531,7 +522,8 @@ should be shown to the user."
        ;; 101 = Switching protocols
        ;; 102 = Processing (Added by DAV)
        (url-mark-buffer-as-dead buffer)
-       (error "HTTP responses in class 1xx not supported (%d)" url-http-response-status))
+       (error "HTTP responses in class 1xx not supported (%d)"
+              url-http-response-status))
       (2                               ; Success
        ;; 200 Ok
        ;; 201 Created
@@ -898,8 +890,11 @@ should be shown to the user."
                 (url-http-activate-callback)
               ;; Call `url-http' again if our connection expired.
               (erase-buffer)
-              (url-http url-current-object url-callback-function
-                        url-callback-arguments (current-buffer))))
+               (let ((url-request-method url-http-method)
+                     (url-request-extra-headers url-http-extra-headers)
+                     (url-request-data url-http-data))
+                 (url-http url-current-object url-callback-function
+                           url-callback-arguments (current-buffer)))))
            ((url-http-parse-headers)
             (url-http-activate-callback))))))
 
@@ -1045,7 +1040,9 @@ the end of the document."
          (setq end-of-headers t
                url-http-end-of-headers 0
                old-http t)
-       (when (re-search-forward "^\r*$" nil t)
+       ;; Blank line at end of headers.
+       (when (re-search-forward "^\r?\n" nil t)
+         (backward-char 1)
          ;; Saw the end of the headers
          (url-http-debug "Saw end of headers... (%s)" (buffer-name))
          (setq url-http-end-of-headers (set-marker (make-marker)
@@ -1155,12 +1152,15 @@ the end of the document."
     (when (eq process-buffer (current-buffer))
       (goto-char (point-max)))))
 
-;;;###autoload
 (defun url-http (url callback cbargs &optional retry-buffer)
   "Retrieve URL via HTTP asynchronously.
 URL must be a parsed URL.  See `url-generic-parse-url' for details.
-When retrieval is completed, the function CALLBACK is executed with
-CBARGS as the arguments.
+
+When retrieval is completed, execute the function CALLBACK, using
+the arguments listed in CBARGS.  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).
 
 Optional arg RETRY-BUFFER, if non-nil, specifies the buffer of a
 previous `url-http' call, which is being re-attempted."
@@ -1301,7 +1301,6 @@ previous `url-http' call, which is being re-attempted."
        (url-request-data nil))
     (url-retrieve-synchronously url)))
 
-;;;###autoload
 (defun url-http-file-exists-p (url)
   (let ((status nil)
        (exists nil)
@@ -1315,7 +1314,6 @@ previous `url-http' call, which is being re-attempted."
       (kill-buffer buffer))
     exists))
 
-;;;###autoload
 (defalias 'url-http-file-readable-p 'url-http-file-exists-p)
 
 (defun url-http-head-file-attributes (url &optional id-format)
@@ -1335,13 +1333,11 @@ previous `url-http' call, which is being re-attempted."
 
 (declare-function url-dav-file-attributes "url-dav" (url &optional id-format))
 
-;;;###autoload
 (defun url-http-file-attributes (url &optional id-format)
   (if (url-dav-supported-p url)
       (url-dav-file-attributes url id-format)
     (url-http-head-file-attributes url id-format)))
 
-;;;###autoload
 (defun url-http-options (url)
   "Return a property list describing options available for URL.
 This list is retrieved using the `OPTIONS' HTTP method.
@@ -1419,9 +1415,7 @@ p3p
 ;; with url-http.el on systems with 8-character file names.
 (require 'tls)
 
-;;;###autoload
 (defconst url-https-default-port 443 "Default HTTPS port.")
-;;;###autoload
 (defconst url-https-asynchronous-p t "HTTPS retrievals are asynchronous.")
 
 ;; FIXME what is the point of this alias being an autoload?