Function: url-open-stream
url-open-stream is an autoloaded and byte-compiled function defined in
url-gw.el.gz.
Signature
(url-open-stream NAME BUFFER HOST SERVICE &optional GATEWAY-METHOD)
Documentation
Open a stream to HOST, possibly via a gateway.
Args per open-network-stream.
Will not make a connection if url-gateway-unplugged is non-nil.
Might do a non-blocking connection; use process-status to check.
Optional arg GATEWAY-METHOD specifies the gateway to be used,
overriding the value of url-gateway-method.
Source Code
;; Defined in /usr/src/emacs/lisp/url/url-gw.el.gz
;;;###autoload
(defun url-open-stream (name buffer host service &optional gateway-method)
"Open a stream to HOST, possibly via a gateway.
Args per `open-network-stream'.
Will not make a connection if `url-gateway-unplugged' is non-nil.
Might do a non-blocking connection; use `process-status' to check.
Optional arg GATEWAY-METHOD specifies the gateway to be used,
overriding the value of `url-gateway-method'."
(unless url-gateway-unplugged
(let* ((gwm (or gateway-method url-gateway-method))
(gw-method (if (and url-gateway-local-host-regexp
(not (eq 'tls gwm))
(not (eq 'ssl gwm))
(string-match
url-gateway-local-host-regexp
host))
'native
gwm))
;; An attempt to deal with denied connections, and attempt
;; to reconnect
;; (cur-retries 0)
;; (retry t)
(conn nil))
;; If the user told us to do DNS for them, do it.
(if url-gateway-broken-resolution
(setq host (url-gateway-nslookup-host host)))
(condition-case nil
;; This is a clean way to ensure the new process inherits the
;; right coding systems in both Emacs and XEmacs.
(let ((coding-system-for-read 'binary)
(coding-system-for-write 'binary))
(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 (and (featurep 'make-network-process)
(url-asynchronous url-current-object)
'(:nowait t))))
('socks
(socks-open-network-stream name buffer host service))
('telnet
(url-open-telnet name buffer host service))
('rlogin
(url-open-rlogin name buffer host service))
(_
(error "Bad setting of url-gateway-method: %s"
url-gateway-method))))))
conn)))