Merge from emacs-24; up to 2014-05-15T16:55:18Z!jan.h.d@swipnet.se
[bpt/emacs.git] / lisp / url / url-gw.el
index 2ba2358..b1cc8a2 100644 (file)
@@ -1,8 +1,9 @@
 ;;; url-gw.el --- Gateway munging for URL loading
 
-;; Copyright (C) 1997-1998, 2004-201 Free Software Foundation, Inc.
+;; Copyright (C) 1997-1998, 2004-2014 Free Software Foundation, Inc.
 
 ;; Author: Bill Perry <wmperry@gnu.org>
+;; Maintainer: emacs-devel@gnu.org
 ;; Keywords: comm, data, processes
 
 ;; This file is part of GNU Emacs.
 
 ;;; Code:
 
-(eval-when-compile (require 'cl))
 (require 'url-vars)
 
 ;; Fixme: support SSH explicitly or via a url-gateway-rlogin-program?
 
 (autoload 'socks-open-network-stream "socks")
-(autoload 'open-ssl-stream "ssl")
-(autoload 'open-tls-stream "tls")
 
 (defgroup url-gateway nil
   "URL gateway variables."
@@ -74,12 +72,12 @@ This list will be executed as a command after logging in via telnet."
   :group 'url-gateway)
 
 (defcustom url-gateway-telnet-login-prompt "^\r*.?login:"
-  "Prompt that tells us we should send our username when loggin in w/telnet."
+  "Prompt that tells us we should send our username when logging in w/telnet."
   :type 'regexp
   :group 'url-gateway)
 
 (defcustom url-gateway-telnet-password-prompt "^\r*.?password:"
-  "Prompt that tells us we should send our password when loggin in w/telnet."
+  "Prompt that tells us we should send our password when logging in w/telnet."
   :type 'regexp
   :group 'url-gateway)
 
@@ -219,13 +217,6 @@ Might do a non-blocking connection; use `process-status' to check."
                               host))
                         'native
                       url-gateway-method))
-;;;    ;; This hack is for OS/2 Emacs so that it will not do bogus CRLF
-;;;    ;; conversions while trying to be 'helpful'
-;;;    (tcp-binary-process-output-services (if (stringp service)
-;;;                                            (list service)
-;;;                                          (list service
-;;;                                                (int-to-string service))))
-
          ;; An attempt to deal with denied connections, and attempt
          ;; to reconnect
          (cur-retries 0)
@@ -242,35 +233,25 @@ Might do a non-blocking connection; use `process-status' to check."
          ;; right coding systems in both Emacs and XEmacs.
          (let ((coding-system-for-read 'binary)
                (coding-system-for-write 'binary))
-           (setq conn (case gw-method
-                        (tls
-                         (funcall (if (fboundp 'open-gnutls-stream)
-                                      'open-gnutls-stream
-                                    'open-tls-stream)
-                                  name buffer host service))
-                        (ssl
-                         (open-ssl-stream name buffer host service))
-                        ((native)
-                         ;; Use non-blocking socket if we can.
-                         (make-network-process :name name :buffer buffer
-                                               :host host :service service
-                                               :nowait
-                                               (featurep 'make-network-process '(:nowait t))))
-                        (socks
+           (setq conn (pcase gw-method
+                        ((or `tls `ssl `native)
+                         (if (eq gw-method 'native)
+                             (setq gw-method 'plain))
+                         (open-network-stream
+                          name buffer host service
+                          :type gw-method
+                          ;; Use non-blocking socket if we can.
+                          :nowait (featurep 'make-network-process
+                                            '(:nowait t))))
+                        (`socks
                          (socks-open-network-stream name buffer host service))
-                        (telnet
+                        (`telnet
                          (url-open-telnet name buffer host service))
-                        (rlogin
+                        (`rlogin
                          (url-open-rlogin name buffer host service))
-                        (otherwise
+                        (_
                          (error "Bad setting of url-gateway-method: %s"
-                                url-gateway-method)))))
-        ;; Ignoring errors here seems wrong.  E.g. it'll throw away the
-        ;; error signaled two lines above.  It was also found inconvenient
-        ;; during debugging.
-       ;; (error
-       ;;  (setq conn nil))
-       )
+                                url-gateway-method))))))
       conn)))
 
 (provide 'url-gw)