aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2011-04-02 19:41:03 -0400
committerChong Yidong2011-04-02 19:41:03 -0400
commitda91b5f294f8ec77f48f1bbe27707a0d33d981e9 (patch)
tree877f9242d950613bfa159fde2ecb9fc915d13ab2
parent1d2e369d6cc534d812f5fc025fd9f1f52e7df710 (diff)
downloademacs-da91b5f294f8ec77f48f1bbe27707a0d33d981e9.tar.gz
emacs-da91b5f294f8ec77f48f1bbe27707a0d33d981e9.zip
Merge open-protocol-stream into open-network-stream.
* lisp/subr.el (open-network-stream): Move to net/network-stream.el. * lisp/gnus/proto-stream.el: Move to net/network-stream.el. * lisp/net/network-stream.el: Move from gnus/proto-stream.el. Change prefix to network-stream throughout. (open-protocol-stream): Merge into open-network-stream, leaving open-protocol-stream as an alias. Handle nil BUFFER args. * lisp/gnus/nnimap.el (nnimap-open-connection-1): Pass explicit :end-of-command parameter to open-protocol-stream. * lisp/emacs-lisp/package.el (package--with-work-buffer): Recognize https URLs. * lisp/url/url-gw.el (url-open-stream): Use new open-network-stream functionality to perform encryption.
-rw-r--r--etc/NEWS6
-rw-r--r--lisp/ChangeLog28
-rw-r--r--lisp/emacs-lisp/package.el2
-rw-r--r--lisp/gnus/ChangeLog7
-rw-r--r--lisp/gnus/nnimap.el8
-rw-r--r--lisp/gnus/nntp.el7
-rw-r--r--lisp/net/network-stream.el (renamed from lisp/gnus/proto-stream.el)210
-rw-r--r--lisp/subr.el22
-rw-r--r--lisp/url/url-gw.el39
9 files changed, 166 insertions, 163 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 521741100f1..a1b0896a643 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -773,6 +773,12 @@ sc.el, x-menu.el, rnews.el, rnewspost.el
773 773
774* Lisp changes in Emacs 24.1 774* Lisp changes in Emacs 24.1
775 775
776** `open-network-stream' can now be used to open an encrypted stream.
777It now accepts an optional `:type' parameter for initiating a TLS
778connection, directly or via STARTTLS. To do STARTTLS, additional
779parameters (`:end-of-command', `:success', `:capabilities-command')
780must also be supplied.
781
776** Code can now use lexical scoping by default instead of dynamic scoping. 782** Code can now use lexical scoping by default instead of dynamic scoping.
777The `lexical-binding' variable lets code use lexical scoping for local 783The `lexical-binding' variable lets code use lexical scoping for local
778variables. It is typically set via file-local variables, in which case it 784variables. It is typically set via file-local variables, in which case it
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 9a5b1fd6cc4..04353b9137c 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,15 @@
12011-04-02 Chong Yidong <cyd@stupidchicken.com>
2
3 * emacs-lisp/package.el (package--with-work-buffer): Recognize
4 https URLs.
5
6 * net/network-stream.el: Move from gnus/proto-stream.el. Change
7 prefix to network-stream throughout.
8 (open-protocol-stream): Merge into open-network-stream, leaving
9 open-protocol-stream as an alias. Handle nil BUFFER args.
10
11 * subr.el (open-network-stream): Move to net/network-stream.el.
12
12011-04-02 Glenn Morris <rgm@gnu.org> 132011-04-02 Glenn Morris <rgm@gnu.org>
2 14
3 * find-dired.el (find-exec-terminator): New option. 15 * find-dired.el (find-exec-terminator): New option.
@@ -210,14 +222,14 @@
210 * textmodes/css.el: 222 * textmodes/css.el:
211 * startup.el: 223 * startup.el:
212 * uniquify.el: 224 * uniquify.el:
213 * minibuffer.el: 225 * minibuffer.el:
214 * newcomment.el: 226 * newcomment.el:
215 * reveal.el: 227 * reveal.el:
216 * server.el: 228 * server.el:
217 * mpc.el: 229 * mpc.el:
218 * emacs-lisp/smie.el: 230 * emacs-lisp/smie.el:
219 * doc-view.el: 231 * doc-view.el:
220 * dired.el: 232 * dired.el:
221 * abbrev.el: Use lexical binding. 233 * abbrev.el: Use lexical binding.
222 234
2232011-04-01 Eli Zaretskii <eliz@gnu.org> 2352011-04-01 Eli Zaretskii <eliz@gnu.org>
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index 5dc2938fe08..6aecc3615f3 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -652,7 +652,7 @@ FILE is the name of a file relative to that base location.
652This macro retrieves FILE from LOCATION into a temporary buffer, 652This macro retrieves FILE from LOCATION into a temporary buffer,
653and evaluates BODY while that buffer is current. This work 653and evaluates BODY while that buffer is current. This work
654buffer is killed afterwards. Return the last value in BODY." 654buffer is killed afterwards. Return the last value in BODY."
655 `(let* ((http (string-match "\\`http:" ,location)) 655 `(let* ((http (string-match "\\`https?:" ,location))
656 (buffer 656 (buffer
657 (if http 657 (if http
658 (url-retrieve-synchronously (concat ,location ,file)) 658 (url-retrieve-synchronously (concat ,location ,file))
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index 37faf83fd12..44c29256b7c 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -1,3 +1,10 @@
12011-04-02 Chong Yidong <cyd@stupidchicken.com>
2
3 * proto-stream.el: Move to Emacs core, at net/network-stream.el.
4
5 * nnimap.el (nnimap-open-connection-1): Pass explicit :end-of-command
6 parameter to open-protocol-stream.
7
12011-04-01 Julien Danjou <julien@danjou.info> 82011-04-01 Julien Danjou <julien@danjou.info>
2 9
3 * mm-view.el (mm-display-inline-fontify): Do not fontify with 10 * mm-view.el (mm-display-inline-fontify): Do not fontify with
diff --git a/lisp/gnus/nnimap.el b/lisp/gnus/nnimap.el
index fa09c7ff165..afdea185dd3 100644
--- a/lisp/gnus/nnimap.el
+++ b/lisp/gnus/nnimap.el
@@ -31,7 +31,11 @@
31 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r)))) 31 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
32 32
33(eval-and-compile 33(eval-and-compile
34 (require 'nnheader)) 34 (require 'nnheader)
35 ;; In Emacs 24, `open-protocol-stream' is an autoloaded alias for
36 ;; `make-network-stream'.
37 (unless (fboundp 'open-protocol-stream)
38 (require 'proto-stream)))
35 39
36(eval-when-compile 40(eval-when-compile
37 (require 'cl)) 41 (require 'cl))
@@ -45,7 +49,6 @@
45(require 'tls) 49(require 'tls)
46(require 'parse-time) 50(require 'parse-time)
47(require 'nnmail) 51(require 'nnmail)
48(require 'proto-stream)
49 52
50(autoload 'auth-source-forget+ "auth-source") 53(autoload 'auth-source-forget+ "auth-source")
51(autoload 'auth-source-search "auth-source") 54(autoload 'auth-source-search "auth-source")
@@ -365,6 +368,7 @@ textual parts.")
365 :return-list t 368 :return-list t
366 :shell-command nnimap-shell-program 369 :shell-command nnimap-shell-program
367 :capability-command "1 CAPABILITY\r\n" 370 :capability-command "1 CAPABILITY\r\n"
371 :end-of-command "\r\n"
368 :success " OK " 372 :success " OK "
369 :starttls-function 373 :starttls-function
370 (lambda (capabilities) 374 (lambda (capabilities)
diff --git a/lisp/gnus/nntp.el b/lisp/gnus/nntp.el
index fa765e17463..3285da513e8 100644
--- a/lisp/gnus/nntp.el
+++ b/lisp/gnus/nntp.el
@@ -27,13 +27,16 @@
27 27
28;; For Emacs <22.2 and XEmacs. 28;; For Emacs <22.2 and XEmacs.
29(eval-and-compile 29(eval-and-compile
30 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r)))) 30 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r)))
31 ;; In Emacs 24, `open-protocol-stream' is an autoloaded alias for
32 ;; `make-network-stream'.
33 (unless (fboundp 'open-protocol-stream)
34 (require 'proto-stream)))
31 35
32(require 'nnheader) 36(require 'nnheader)
33(require 'nnoo) 37(require 'nnoo)
34(require 'gnus-util) 38(require 'gnus-util)
35(require 'gnus) 39(require 'gnus)
36(require 'proto-stream)
37(require 'gnus-group) ;; gnus-group-name-charset 40(require 'gnus-group) ;; gnus-group-name-charset
38 41
39(nnoo-declare nntp) 42(nnoo-declare nntp)
diff --git a/lisp/gnus/proto-stream.el b/lisp/net/network-stream.el
index 45cc974e7a9..070cd2641db 100644
--- a/lisp/gnus/proto-stream.el
+++ b/lisp/net/network-stream.el
@@ -1,4 +1,4 @@
1;;; proto-stream.el --- negotiating TLS, STARTTLS and other connections 1;;; network-stream.el --- open network processes, possibly with encryption
2 2
3;; Copyright (C) 2010-2011 Free Software Foundation, Inc. 3;; Copyright (C) 2010-2011 Free Software Foundation, Inc.
4 4
@@ -22,20 +22,14 @@
22 22
23;;; Commentary: 23;;; Commentary:
24 24
25;; This library is meant to provide the glue between modules that want 25;; This library provides the function `open-network-stream', which provides a
26;; to establish a network connection to a server for protocols such as 26;; higher-level interface for opening TCP network processes than the built-in
27;; IMAP, NNTP, SMTP and POP3. 27;; function `make-network-process'. In addition to plain connections, it
28 28;; supports TLS/SSL and STARTTLS connections.
29;; The main problem is that there's more than a couple of interfaces
30;; towards doing this. You have normal, plain connections, which are
31;; no trouble at all, but you also have TLS/SSL connections, and you
32;; have STARTTLS. Negotiating this for each protocol can be rather
33;; tedious, so this library provides a single entry point, and hides
34;; much of the ugliness.
35 29
36;; Usage example: 30;; Usage example:
37 31
38;; (open-protocol-stream 32;; (open-network-stream
39;; "*nnimap*" buffer address port 33;; "*nnimap*" buffer address port
40;; :type 'network 34;; :type 'network
41;; :capability-command "1 CAPABILITY\r\n" 35;; :capability-command "1 CAPABILITY\r\n"
@@ -55,14 +49,24 @@
55 (proc type &optional priority-string trustfiles keyfiles)) 49 (proc type &optional priority-string trustfiles keyfiles))
56 50
57;;;###autoload 51;;;###autoload
58(defun open-protocol-stream (name buffer host service &rest parameters) 52(defun open-network-stream (name buffer host service &rest parameters)
59 "Open a network stream to HOST, possibly with encryption. 53 "Open a TCP connection to HOST, optionally with encryption.
60Normally, return a network process object; with a non-nil 54Normally, return a network process object; with a non-nil
61:return-list parameter, return a list instead (see below). 55:return-list parameter, return a list instead (see below).
56Input and output work as for subprocesses; `delete-process'
57closes it.
58
59NAME is the name for the process. It is modified if necessary to
60 make it unique.
61BUFFER is a buffer or buffer name to associate with the process.
62 Process output goes at end of that buffer. BUFFER may be nil,
63 meaning that the process is not associated with any buffer.
64HOST is the name or IP address of the host to connect to.
65SERVICE is the name of the service desired, or an integer specifying
66 a port number to connect to.
62 67
63The first four parameters, NAME, BUFFER, HOST, and SERVICE, have 68The remaining PARAMETERS should be a sequence of keywords and
64the same meanings as in `open-network-stream'. The remaining 69values:
65PARAMETERS should be a sequence of keywords and values:
66 70
67:type specifies the connection type, one of the following: 71:type specifies the connection type, one of the following:
68 nil or `network' 72 nil or `network'
@@ -92,7 +96,6 @@ PARAMETERS should be a sequence of keywords and values:
92 or `tls' (TLS-encrypted). 96 or `tls' (TLS-encrypted).
93 97
94:end-of-command specifies a regexp matching the end of a command. 98:end-of-command specifies a regexp matching the end of a command.
95 If non-nil, it defaults to \"\\n\".
96 99
97:success specifies a regexp matching a message indicating a 100:success specifies a regexp matching a message indicating a
98 successful STARTTLS negotiation. For instance, the default 101 successful STARTTLS negotiation. For instance, the default
@@ -106,6 +109,8 @@ PARAMETERS should be a sequence of keywords and values:
106 This function should take one parameter, the response to the 109 This function should take one parameter, the response to the
107 capability command, and should return the command to switch on 110 capability command, and should return the command to switch on
108 STARTTLS if the server supports STARTTLS, and nil otherwise." 111 STARTTLS if the server supports STARTTLS, and nil otherwise."
112 (unless (featurep 'make-network-process)
113 (error "Emacs was compiled without networking support"))
109 (let ((type (plist-get parameters :type)) 114 (let ((type (plist-get parameters :type))
110 (return-list (plist-get parameters :return-list))) 115 (return-list (plist-get parameters :return-list)))
111 (if (and (not return-list) 116 (if (and (not return-list)
@@ -113,21 +118,24 @@ PARAMETERS should be a sequence of keywords and values:
113 (and (memq type '(nil network)) 118 (and (memq type '(nil network))
114 (not (and (plist-get parameters :success) 119 (not (and (plist-get parameters :success)
115 (plist-get parameters :capability-command)))))) 120 (plist-get parameters :capability-command))))))
116 ;; The simplest case is equivalent to `open-network-stream'. 121 ;; The simplest case: wrapper around `make-network-process'.
117 (open-network-stream name buffer host service) 122 (make-network-process :name name :buffer buffer
118 ;; For everything else, refer to proto-stream-open-*. 123 :host host :service service)
119 (unless (plist-get parameters :end-of-command) 124 (let ((work-buffer (or buffer
120 (setq parameters (append '(:end-of-command "\r\n") parameters))) 125 (generate-new-buffer " *stream buffer*")))
121 (let* ((connection-function 126 (fun (cond ((eq type 'plain) 'network-stream-open-plain)
122 (cond 127 ((memq type '(nil network starttls))
123 ((eq type 'plain) 'proto-stream-open-plain) 128 'network-stream-open-starttls)
124 ((memq type '(nil network starttls)) 129 ((memq type '(tls ssl)) 'network-stream-open-tls)
125 'proto-stream-open-starttls) 130 ((eq type 'shell) 'network-stream-open-shell)
126 ((memq type '(tls ssl)) 'proto-stream-open-tls) 131 (t (error "Invalid connection type %s" type))))
127 ((eq type 'shell) 'proto-stream-open-shell) 132 result)
128 (t (error "Invalid connection type %s" type)))) 133 (unwind-protect
129 (result (funcall connection-function 134 (setq result (funcall fun name work-buffer host service parameters))
130 name buffer host service parameters))) 135 (unless buffer
136 (and (processp (car result))
137 (set-process-buffer (car result) nil))
138 (kill-buffer work-buffer)))
131 (if return-list 139 (if return-list
132 (list (car result) 140 (list (car result)
133 :greeting (nth 1 result) 141 :greeting (nth 1 result)
@@ -135,16 +143,20 @@ PARAMETERS should be a sequence of keywords and values:
135 :type (nth 3 result)) 143 :type (nth 3 result))
136 (car result)))))) 144 (car result))))))
137 145
138(defun proto-stream-open-plain (name buffer host service parameters) 146;;;###autoload
147(defalias 'open-protocol-stream 'open-network-stream)
148
149(defun network-stream-open-plain (name buffer host service parameters)
139 (let ((start (with-current-buffer buffer (point))) 150 (let ((start (with-current-buffer buffer (point)))
140 (stream (open-network-stream name buffer host service))) 151 (stream (make-network-process :name name :buffer buffer
152 :host host :service service)))
141 (list stream 153 (list stream
142 (proto-stream-get-response stream start 154 (network-stream-get-response stream start
143 (plist-get parameters :end-of-command)) 155 (plist-get parameters :end-of-command))
144 nil 156 nil
145 'plain))) 157 'plain)))
146 158
147(defun proto-stream-open-starttls (name buffer host service parameters) 159(defun network-stream-open-starttls (name buffer host service parameters)
148 (let* ((start (with-current-buffer buffer (point))) 160 (let* ((start (with-current-buffer buffer (point)))
149 (require-tls (eq (plist-get parameters :type) 'starttls)) 161 (require-tls (eq (plist-get parameters :type) 'starttls))
150 (starttls-function (plist-get parameters :starttls-function)) 162 (starttls-function (plist-get parameters :starttls-function))
@@ -152,11 +164,10 @@ PARAMETERS should be a sequence of keywords and values:
152 (capability-command (plist-get parameters :capability-command)) 164 (capability-command (plist-get parameters :capability-command))
153 (eoc (plist-get parameters :end-of-command)) 165 (eoc (plist-get parameters :end-of-command))
154 ;; Return (STREAM GREETING CAPABILITIES RESULTING-TYPE) 166 ;; Return (STREAM GREETING CAPABILITIES RESULTING-TYPE)
155 (stream (open-network-stream name buffer host service)) 167 (stream (make-network-process :name name :buffer buffer
156 (greeting (proto-stream-get-response stream start eoc)) 168 :host host :service service))
157 (capabilities (when capability-command 169 (greeting (network-stream-get-response stream start eoc))
158 (proto-stream-command stream 170 (capabilities (network-stream-command stream capability-command eoc))
159 capability-command eoc)))
160 (resulting-type 'plain) 171 (resulting-type 'plain)
161 starttls-command) 172 starttls-command)
162 173
@@ -179,9 +190,9 @@ PARAMETERS should be a sequence of keywords and values:
179 ;; care about the identity of the peer. 190 ;; care about the identity of the peer.
180 (cons "--insecure" starttls-extra-arguments)))) 191 (cons "--insecure" starttls-extra-arguments))))
181 (setq stream (starttls-open-stream name buffer host service))) 192 (setq stream (starttls-open-stream name buffer host service)))
182 (proto-stream-get-response stream start eoc)) 193 (network-stream-get-response stream start eoc))
183 (when (string-match success-string 194 (when (string-match success-string
184 (proto-stream-command stream starttls-command eoc)) 195 (network-stream-command stream starttls-command eoc))
185 ;; The server said it was OK to begin STARTTLS negotiations. 196 ;; The server said it was OK to begin STARTTLS negotiations.
186 (if (fboundp 'open-gnutls-stream) 197 (if (fboundp 'open-gnutls-stream)
187 (gnutls-negotiate stream nil) 198 (gnutls-negotiate stream nil)
@@ -192,11 +203,13 @@ PARAMETERS should be a sequence of keywords and values:
192 ;; We didn't successfully negotiate STARTTLS; if TLS 203 ;; We didn't successfully negotiate STARTTLS; if TLS
193 ;; isn't demanded, reopen an unencrypted connection. 204 ;; isn't demanded, reopen an unencrypted connection.
194 (unless require-tls 205 (unless require-tls
195 (setq stream (open-network-stream name buffer host service)) 206 (setq stream
196 (proto-stream-get-response stream start eoc))) 207 (make-network-process :name name :buffer buffer
208 :host host :service service))
209 (network-stream-get-response stream start eoc)))
197 ;; Re-get the capabilities, which may have now changed. 210 ;; Re-get the capabilities, which may have now changed.
198 (setq capabilities 211 (setq capabilities
199 (proto-stream-command stream capability-command eoc)))) 212 (network-stream-command stream capability-command eoc))))
200 213
201 ;; If TLS is mandatory, close the connection if it's unencrypted. 214 ;; If TLS is mandatory, close the connection if it's unencrypted.
202 (and require-tls 215 (and require-tls
@@ -205,70 +218,69 @@ PARAMETERS should be a sequence of keywords and values:
205 ;; Return value: 218 ;; Return value:
206 (list stream greeting capabilities resulting-type))) 219 (list stream greeting capabilities resulting-type)))
207 220
208(defun proto-stream-command (stream command eoc) 221(defun network-stream-command (stream command eoc)
209 (let ((start (with-current-buffer (process-buffer stream) (point-max)))) 222 (when command
210 (process-send-string stream command) 223 (let ((start (with-current-buffer (process-buffer stream) (point-max))))
211 (proto-stream-get-response stream start eoc))) 224 (process-send-string stream command)
212 225 (network-stream-get-response stream start eoc))))
213(defun proto-stream-get-response (stream start end-of-command) 226
214 (with-current-buffer (process-buffer stream) 227(defun network-stream-get-response (stream start end-of-command)
215 (save-excursion 228 (when end-of-command
216 (goto-char start) 229 (with-current-buffer (process-buffer stream)
217 (while (and (memq (process-status stream) 230 (save-excursion
218 '(open run)) 231 (goto-char start)
219 (not (re-search-forward end-of-command nil t))) 232 (while (and (memq (process-status stream) '(open run))
220 (accept-process-output stream 0 50) 233 (not (re-search-forward end-of-command nil t)))
221 (goto-char start)) 234 (accept-process-output stream 0 50)
222 (if (= start (point)) 235 (goto-char start))
223 ;; The process died; return nil. 236 ;; Return the data we got back, or nil if the process died.
224 nil 237 (unless (= start (point))
225 ;; Return the data we got back. 238 (buffer-substring start (point)))))))
226 (buffer-substring start (point)))))) 239
227 240(defun network-stream-open-tls (name buffer host service parameters)
228(defun proto-stream-open-tls (name buffer host service parameters)
229 (with-current-buffer buffer 241 (with-current-buffer buffer
230 (let ((start (point-max)) 242 (let* ((start (point-max))
231 (stream 243 (use-builtin-gnutls (fboundp 'open-gnutls-stream))
232 (funcall (if (fboundp 'open-gnutls-stream) 244 (stream
233 'open-gnutls-stream 245 (funcall (if use-builtin-gnutls
234 'open-tls-stream) 246 'open-gnutls-stream
235 name buffer host service)) 247 'open-tls-stream)
236 (eoc (plist-get parameters :end-of-command))) 248 name buffer host service))
249 (eoc (plist-get parameters :end-of-command)))
237 (if (null stream) 250 (if (null stream)
238 (list nil nil nil 'plain) 251 (list nil nil nil 'plain)
239 ;; If we're using tls.el, we have to delete the output from 252 ;; If we're using tls.el, we have to delete the output from
240 ;; openssl/gnutls-cli. 253 ;; openssl/gnutls-cli.
241 (unless (fboundp 'open-gnutls-stream) 254 (when (and (null use-builtin-gnutls) eoc)
242 (proto-stream-get-response stream start eoc) 255 (network-stream-get-response stream start eoc)
243 (goto-char (point-min)) 256 (goto-char (point-min))
244 (when (re-search-forward eoc nil t) 257 (when (re-search-forward eoc nil t)
245 (goto-char (match-beginning 0)) 258 (goto-char (match-beginning 0))
246 (delete-region (point-min) (line-beginning-position)))) 259 (delete-region (point-min) (line-beginning-position))))
247 (proto-stream-capability-open start stream parameters 'tls))))) 260 (let* ((capability-command (plist-get parameters :capability-command)))
261 (list stream
262 (network-stream-get-response stream start eoc)
263 (network-stream-command stream capability-command eoc)
264 'tls))))))
248 265
249(defun proto-stream-open-shell (name buffer host service parameters) 266(defun network-stream-open-shell (name buffer host service parameters)
250 (require 'format-spec) 267 (require 'format-spec)
251 (proto-stream-capability-open
252 (with-current-buffer buffer (point))
253 (let ((process-connection-type nil))
254 (start-process name buffer shell-file-name
255 shell-command-switch
256 (format-spec
257 (plist-get parameters :shell-command)
258 (format-spec-make
259 ?s host
260 ?p service))))
261 parameters 'plain))
262
263(defun proto-stream-capability-open (start stream parameters stream-type)
264 (let* ((capability-command (plist-get parameters :capability-command)) 268 (let* ((capability-command (plist-get parameters :capability-command))
265 (eoc (plist-get parameters :end-of-command)) 269 (eoc (plist-get parameters :end-of-command))
266 (greeting (proto-stream-get-response stream start eoc))) 270 (start (with-current-buffer buffer (point)))
267 (list stream greeting 271 (stream (let ((process-connection-type nil))
268 (and capability-command 272 (start-process name buffer shell-file-name
269 (proto-stream-command stream capability-command eoc)) 273 shell-command-switch
270 stream-type))) 274 (format-spec
275 (plist-get parameters :shell-command)
276 (format-spec-make
277 ?s host
278 ?p service))))))
279 (list stream
280 (network-stream-get-response stream start eoc)
281 (network-stream-command stream capability-command eoc)
282 'plain)))
271 283
272(provide 'proto-stream) 284(provide 'network-stream)
273 285
274;;; proto-stream.el ends here 286;;; network-stream.el ends here
diff --git a/lisp/subr.el b/lisp/subr.el
index e6e0c62e0b4..387d538b69d 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -1792,28 +1792,6 @@ Signal an error if the program returns with a non-zero exit status."
1792 (forward-line 1)) 1792 (forward-line 1))
1793 (nreverse lines))))) 1793 (nreverse lines)))))
1794 1794
1795;; open-network-stream is a wrapper around make-network-process.
1796
1797(when (featurep 'make-network-process)
1798 (defun open-network-stream (name buffer host service)
1799 "Open a TCP connection for a service to a host.
1800Returns a subprocess-object to represent the connection.
1801Input and output work as for subprocesses; `delete-process' closes it.
1802
1803NAME is the name for the process. It is modified if necessary to make
1804 it unique.
1805BUFFER is the buffer (or buffer name) to associate with the
1806 process. Process output goes at end of that buffer. BUFFER may
1807 be nil, meaning that this process is not associated with any buffer.
1808HOST is the name or IP address of the host to connect to.
1809SERVICE is the name of the service desired, or an integer specifying
1810 a port number to connect to.
1811
1812This is a wrapper around `make-network-process', and only offers a
1813subset of its functionality."
1814 (make-network-process :name name :buffer buffer
1815 :host host :service service)))
1816
1817;; compatibility 1795;; compatibility
1818 1796
1819(make-obsolete 1797(make-obsolete
diff --git a/lisp/url/url-gw.el b/lisp/url/url-gw.el
index 2ba23583528..7d80f2f6725 100644
--- a/lisp/url/url-gw.el
+++ b/lisp/url/url-gw.el
@@ -28,8 +28,6 @@
28;; Fixme: support SSH explicitly or via a url-gateway-rlogin-program? 28;; Fixme: support SSH explicitly or via a url-gateway-rlogin-program?
29 29
30(autoload 'socks-open-network-stream "socks") 30(autoload 'socks-open-network-stream "socks")
31(autoload 'open-ssl-stream "ssl")
32(autoload 'open-tls-stream "tls")
33 31
34(defgroup url-gateway nil 32(defgroup url-gateway nil
35 "URL gateway variables." 33 "URL gateway variables."
@@ -219,13 +217,6 @@ Might do a non-blocking connection; use `process-status' to check."
219 host)) 217 host))
220 'native 218 'native
221 url-gateway-method)) 219 url-gateway-method))
222;;; ;; This hack is for OS/2 Emacs so that it will not do bogus CRLF
223;;; ;; conversions while trying to be 'helpful'
224;;; (tcp-binary-process-output-services (if (stringp service)
225;;; (list service)
226;;; (list service
227;;; (int-to-string service))))
228
229 ;; An attempt to deal with denied connections, and attempt 220 ;; An attempt to deal with denied connections, and attempt
230 ;; to reconnect 221 ;; to reconnect
231 (cur-retries 0) 222 (cur-retries 0)
@@ -243,19 +234,15 @@ Might do a non-blocking connection; use `process-status' to check."
243 (let ((coding-system-for-read 'binary) 234 (let ((coding-system-for-read 'binary)
244 (coding-system-for-write 'binary)) 235 (coding-system-for-write 'binary))
245 (setq conn (case gw-method 236 (setq conn (case gw-method
246 (tls 237 ((tls ssl native)
247 (funcall (if (fboundp 'open-gnutls-stream) 238 (if (eq gw-method 'native)
248 'open-gnutls-stream 239 (setq gw-method 'plain))
249 'open-tls-stream) 240 (open-network-stream
250 name buffer host service)) 241 name buffer host service
251 (ssl 242 :type gw-method
252 (open-ssl-stream name buffer host service)) 243 ;; Use non-blocking socket if we can.
253 ((native) 244 :nowait (featurep 'make-network-process
254 ;; Use non-blocking socket if we can. 245 '(:nowait t))))
255 (make-network-process :name name :buffer buffer
256 :host host :service service
257 :nowait
258 (featurep 'make-network-process '(:nowait t))))
259 (socks 246 (socks
260 (socks-open-network-stream name buffer host service)) 247 (socks-open-network-stream name buffer host service))
261 (telnet 248 (telnet
@@ -264,13 +251,7 @@ Might do a non-blocking connection; use `process-status' to check."
264 (url-open-rlogin name buffer host service)) 251 (url-open-rlogin name buffer host service))
265 (otherwise 252 (otherwise
266 (error "Bad setting of url-gateway-method: %s" 253 (error "Bad setting of url-gateway-method: %s"
267 url-gateway-method))))) 254 url-gateway-method))))))
268 ;; Ignoring errors here seems wrong. E.g. it'll throw away the
269 ;; error signaled two lines above. It was also found inconvenient
270 ;; during debugging.
271 ;; (error
272 ;; (setq conn nil))
273 )
274 conn))) 255 conn)))
275 256
276(provide 'url-gw) 257(provide 'url-gw)