aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorRobert Pluim2020-04-02 18:41:33 +0200
committerRobert Pluim2020-04-07 14:32:44 +0200
commit6382e1330814ca4df20eeccd8b4ef9ca17b997af (patch)
treeda17e0f14357e46bacb49658b6d8ee13e4354849 /lisp
parent23b04ef0e7d03cd7c178b544d5fff2bda4c7c504 (diff)
downloademacs-6382e1330814ca4df20eeccd8b4ef9ca17b997af.tar.gz
emacs-6382e1330814ca4df20eeccd8b4ef9ca17b997af.zip
Add :coding support to open-network-stream and open-gnutls-stream
* doc/lispref/processes.texi (Network): Describe :coding keyword support. * doc/misc/emacs-gnutls.texi (Help For Developers): Describe :coding keyword support. * etc/NEWS: Announce change to open-network-stream and open-gnutls-stream. * lisp/net/gnutls.el (open-gnutls-stream): Add support for :coding, pass it down to open-network-stream. * lisp/net/network-stream.el (open-network-stream) (network-stream-open-plain, network-stream-open-starttls): Add support for :coding, pass it down to make-network-process. (network-stream-open-shell): Add support-for :coding, use set-process-coding-system to set it after process creation.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/net/gnutls.el8
-rw-r--r--lisp/net/network-stream.el24
2 files changed, 25 insertions, 7 deletions
diff --git a/lisp/net/gnutls.el b/lisp/net/gnutls.el
index 459156e6d27..cd86b4dea65 100644
--- a/lisp/net/gnutls.el
+++ b/lisp/net/gnutls.el
@@ -169,8 +169,9 @@ Third arg HOST is the name of the host to connect to, or its IP address.
169Fourth arg SERVICE is the name of the service desired, or an integer 169Fourth arg SERVICE is the name of the service desired, or an integer
170specifying a port number to connect to. 170specifying a port number to connect to.
171Fifth arg PARAMETERS is an optional list of keyword/value pairs. 171Fifth arg PARAMETERS is an optional list of keyword/value pairs.
172Only :client-certificate and :nowait keywords are recognized, and 172Only :client-certificate, :nowait, and :coding keywords are
173have the same meaning as for `open-network-stream'. 173recognized, and have the same meaning as for
174`open-network-stream'.
174For historical reasons PARAMETERS can also be a symbol, which is 175For historical reasons PARAMETERS can also be a symbol, which is
175interpreted the same as passing a list containing :nowait and the 176interpreted the same as passing a list containing :nowait and the
176value of that symbol. 177value of that symbol.
@@ -208,7 +209,8 @@ trust and key files, and priority string."
208 (gnutls-boot-parameters 209 (gnutls-boot-parameters
209 :type 'gnutls-x509pki 210 :type 'gnutls-x509pki
210 :keylist keylist 211 :keylist keylist
211 :hostname (puny-encode-domain host))))))) 212 :hostname (puny-encode-domain host))))
213 :coding (plist-get parameters :coding))))
212 (if nowait 214 (if nowait
213 process 215 process
214 (gnutls-negotiate :process process 216 (gnutls-negotiate :process process
diff --git a/lisp/net/network-stream.el b/lisp/net/network-stream.el
index e99d7a372c0..1d5cf382a84 100644
--- a/lisp/net/network-stream.el
+++ b/lisp/net/network-stream.el
@@ -113,6 +113,10 @@ values:
113 `ssl' -- Equivalent to `tls'. 113 `ssl' -- Equivalent to `tls'.
114 `shell' -- A shell connection. 114 `shell' -- A shell connection.
115 115
116:coding is a symbol or a cons used to specify the coding systems
117used to decode and encode the data which the process reads and
118writes. See `make-network-process' for details.
119
116:return-list specifies this function's return value. 120:return-list specifies this function's return value.
117 If omitted or nil, return a process object. A non-nil means to 121 If omitted or nil, return a process object. A non-nil means to
118 return (PROC . PROPS), where PROC is a process object and PROPS 122 return (PROC . PROPS), where PROC is a process object and PROPS
@@ -189,7 +193,8 @@ gnutls-boot (as returned by `gnutls-boot-parameters')."
189 :host (puny-encode-domain host) :service service 193 :host (puny-encode-domain host) :service service
190 :nowait (plist-get parameters :nowait) 194 :nowait (plist-get parameters :nowait)
191 :tls-parameters 195 :tls-parameters
192 (plist-get parameters :tls-parameters)) 196 (plist-get parameters :tls-parameters)
197 :coding (plist-get parameters :coding))
193 (let ((work-buffer (or buffer 198 (let ((work-buffer (or buffer
194 (generate-new-buffer " *stream buffer*"))) 199 (generate-new-buffer " *stream buffer*")))
195 (fun (cond ((and (eq type 'plain) 200 (fun (cond ((and (eq type 'plain)
@@ -249,7 +254,8 @@ gnutls-boot (as returned by `gnutls-boot-parameters')."
249 (stream (make-network-process :name name :buffer buffer 254 (stream (make-network-process :name name :buffer buffer
250 :host (puny-encode-domain host) 255 :host (puny-encode-domain host)
251 :service service 256 :service service
252 :nowait (plist-get parameters :nowait)))) 257 :nowait (plist-get parameters :nowait)
258 :coding (plist-get parameters :coding))))
253 (when (plist-get parameters :warn-unless-encrypted) 259 (when (plist-get parameters :warn-unless-encrypted)
254 (setq stream (nsm-verify-connection stream host service nil t))) 260 (setq stream (nsm-verify-connection stream host service nil t)))
255 (list stream 261 (list stream
@@ -270,7 +276,8 @@ gnutls-boot (as returned by `gnutls-boot-parameters')."
270 ;; Return (STREAM GREETING CAPABILITIES RESULTING-TYPE) 276 ;; Return (STREAM GREETING CAPABILITIES RESULTING-TYPE)
271 (stream (make-network-process :name name :buffer buffer 277 (stream (make-network-process :name name :buffer buffer
272 :host (puny-encode-domain host) 278 :host (puny-encode-domain host)
273 :service service)) 279 :service service
280 :coding (plist-get parameters :coding)))
274 (greeting (and (not (plist-get parameters :nogreeting)) 281 (greeting (and (not (plist-get parameters :nogreeting))
275 (network-stream-get-response stream start eoc))) 282 (network-stream-get-response stream start eoc)))
276 (capabilities (network-stream-command stream capability-command 283 (capabilities (network-stream-command stream capability-command
@@ -350,7 +357,8 @@ gnutls-boot (as returned by `gnutls-boot-parameters')."
350 (setq stream 357 (setq stream
351 (make-network-process :name name :buffer buffer 358 (make-network-process :name name :buffer buffer
352 :host (puny-encode-domain host) 359 :host (puny-encode-domain host)
353 :service service)) 360 :service service
361 :coding (plist-get parameters :coding)))
354 (network-stream-get-response stream start eoc))) 362 (network-stream-get-response stream start eoc)))
355 (unless (process-live-p stream) 363 (unless (process-live-p stream)
356 (error "Unable to negotiate a TLS connection with %s/%s" 364 (error "Unable to negotiate a TLS connection with %s/%s"
@@ -453,6 +461,7 @@ gnutls-boot (as returned by `gnutls-boot-parameters')."
453 (let* ((capability-command (plist-get parameters :capability-command)) 461 (let* ((capability-command (plist-get parameters :capability-command))
454 (eoc (plist-get parameters :end-of-command)) 462 (eoc (plist-get parameters :end-of-command))
455 (start (with-current-buffer buffer (point))) 463 (start (with-current-buffer buffer (point)))
464 (coding (plist-get parameters :coding))
456 (stream (let ((process-connection-type nil)) 465 (stream (let ((process-connection-type nil))
457 (start-process name buffer shell-file-name 466 (start-process name buffer shell-file-name
458 shell-command-switch 467 shell-command-switch
@@ -461,6 +470,13 @@ gnutls-boot (as returned by `gnutls-boot-parameters')."
461 (format-spec-make 470 (format-spec-make
462 ?s host 471 ?s host
463 ?p service)))))) 472 ?p service))))))
473 (when coding (if (consp coding)
474 (set-process-coding-system stream
475 (car coding)
476 (cdr coding))
477 (set-process-coding-system stream
478 coding
479 coding)))
464 (list stream 480 (list stream
465 (network-stream-get-response stream start eoc) 481 (network-stream-get-response stream start eoc)
466 (network-stream-command stream capability-command 482 (network-stream-command stream capability-command