refactor(3p/lisp/mime4cl): rename :stream to :underlying-stream
This makes sure that initializing coder-stream-mixin (for the most part) has the same interface as initializing qbase64:decode-stream. This will make integrating that as a faster replacement to mime4cl:base64-decoder-stream a bit easier. The idea is to replace the char by char base64 decoder with one that supports read-sequence. After that deliminited-input-stream needs to gain support for read-sequence as well, so we can actually take advantage of this fact. Finally, we'll have to evaluate the remaining decoders and think about switching the (base64) encoders over as well. Change-Id: If971da02437506e00a7c9fab2b94efc42725e62d Reviewed-on: https://cl.tvl.fyi/c/depot/+/8555 Reviewed-by: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI Autosubmit: sterni <sternenseemann@systemli.org>
This commit is contained in:
parent
f1604c99e5
commit
7c6806cfa7
2 changed files with 12 additions and 11 deletions
7
third_party/lisp/mime4cl/mime.lisp
vendored
7
third_party/lisp/mime4cl/mime.lisp
vendored
|
@ -687,7 +687,7 @@ list of MIME parts."
|
||||||
'("message" "rfc822" ())
|
'("message" "rfc822" ())
|
||||||
'("text" "plain" (("charset" . "us-ascii"))))
|
'("text" "plain" (("charset" . "us-ascii"))))
|
||||||
in (make-instance 'delimited-input-stream
|
in (make-instance 'delimited-input-stream
|
||||||
:stream stream
|
:underlying-stream stream
|
||||||
:dont-close t
|
:dont-close t
|
||||||
:start start
|
:start start
|
||||||
:end end)
|
:end end)
|
||||||
|
@ -729,7 +729,7 @@ guessed from the headers, use the *DEFAULT-TYPE*."
|
||||||
(flet ((hdr (what)
|
(flet ((hdr (what)
|
||||||
(header what headers)))
|
(header what headers)))
|
||||||
(destructuring-bind (type subtype parms)
|
(destructuring-bind (type subtype parms)
|
||||||
(or
|
(or
|
||||||
(aand (hdr :content-type)
|
(aand (hdr :content-type)
|
||||||
(parse-content-type it))
|
(parse-content-type it))
|
||||||
*default-type*)
|
*default-type*)
|
||||||
|
@ -823,7 +823,8 @@ returns a MIME-MESSAGE object."
|
||||||
'quoted-printable-encoder-input-stream)
|
'quoted-printable-encoder-input-stream)
|
||||||
(t
|
(t
|
||||||
'8bit-encoder-input-stream))
|
'8bit-encoder-input-stream))
|
||||||
:stream (make-instance 'binary-input-adapter-stream :source body))))
|
:underlying-stream
|
||||||
|
(make-instance 'binary-input-adapter-stream :source body))))
|
||||||
|
|
||||||
(defun choose-boundary (parts &optional default)
|
(defun choose-boundary (parts &optional default)
|
||||||
(labels ((match-in-parts (boundary parts)
|
(labels ((match-in-parts (boundary parts)
|
||||||
|
|
16
third_party/lisp/mime4cl/streams.lisp
vendored
16
third_party/lisp/mime4cl/streams.lisp
vendored
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
(defclass coder-stream-mixin ()
|
(defclass coder-stream-mixin ()
|
||||||
((real-stream :type stream
|
((real-stream :type stream
|
||||||
:initarg :stream
|
:initarg :underlying-stream
|
||||||
:reader real-stream)
|
:reader real-stream)
|
||||||
(dont-close :initform nil
|
(dont-close :initform nil
|
||||||
:initarg :dont-close)))
|
:initarg :dont-close)))
|
||||||
|
@ -52,7 +52,7 @@
|
||||||
|
|
||||||
(defmethod initialize-instance :after ((stream coder-stream-mixin) &key &allow-other-keys)
|
(defmethod initialize-instance :after ((stream coder-stream-mixin) &key &allow-other-keys)
|
||||||
(unless (slot-boundp stream 'real-stream)
|
(unless (slot-boundp stream 'real-stream)
|
||||||
(error "REAL-STREAM is unbound. Must provide a :STREAM argument.")))
|
(error "REAL-STREAM is unbound. Must provide a :UNDERLYING-STREAM argument.")))
|
||||||
|
|
||||||
(defmethod initialize-instance ((stream coder-output-stream-mixin) &key &allow-other-keys)
|
(defmethod initialize-instance ((stream coder-output-stream-mixin) &key &allow-other-keys)
|
||||||
(call-next-method)
|
(call-next-method)
|
||||||
|
@ -261,7 +261,7 @@ in a stream of character."))
|
||||||
(defmethod initialize-instance ((stream delimited-input-stream) &key &allow-other-keys)
|
(defmethod initialize-instance ((stream delimited-input-stream) &key &allow-other-keys)
|
||||||
(call-next-method)
|
(call-next-method)
|
||||||
(unless (slot-boundp stream 'real-stream)
|
(unless (slot-boundp stream 'real-stream)
|
||||||
(error "REAL-STREAM is unbound. Must provide a :STREAM argument."))
|
(error "REAL-STREAM is unbound. Must provide a :UNDERLYING-STREAM argument."))
|
||||||
(with-slots (start-offset) stream
|
(with-slots (start-offset) stream
|
||||||
(file-position stream start-offset)))
|
(file-position stream start-offset)))
|
||||||
|
|
||||||
|
@ -321,7 +321,7 @@ in a stream of character."))
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
(defstruct file-portion
|
(defstruct file-portion
|
||||||
data ; string or a pathname
|
data ; string or a pathname
|
||||||
encoding
|
encoding
|
||||||
start
|
start
|
||||||
end)
|
end)
|
||||||
|
@ -332,17 +332,17 @@ in a stream of character."))
|
||||||
(pathname
|
(pathname
|
||||||
(be stream (open data)
|
(be stream (open data)
|
||||||
(make-instance 'delimited-input-stream
|
(make-instance 'delimited-input-stream
|
||||||
:stream stream
|
:underlying-stream stream
|
||||||
:start (file-portion-start file-portion)
|
:start (file-portion-start file-portion)
|
||||||
:end (file-portion-end file-portion))))
|
:end (file-portion-end file-portion))))
|
||||||
(string
|
(string
|
||||||
(make-instance 'delimited-input-stream
|
(make-instance 'delimited-input-stream
|
||||||
:stream (make-string-input-stream data)
|
:underlying-stream (make-string-input-stream data)
|
||||||
:start (file-portion-start file-portion)
|
:start (file-portion-start file-portion)
|
||||||
:end (file-portion-end file-portion)))
|
:end (file-portion-end file-portion)))
|
||||||
(stream
|
(stream
|
||||||
(make-instance 'delimited-input-stream
|
(make-instance 'delimited-input-stream
|
||||||
:stream data
|
:underyling-stream data
|
||||||
:dont-close t
|
:dont-close t
|
||||||
:start (file-portion-start file-portion)
|
:start (file-portion-start file-portion)
|
||||||
:end (file-portion-end file-portion))))))
|
:end (file-portion-end file-portion))))))
|
||||||
|
@ -352,4 +352,4 @@ in a stream of character."))
|
||||||
(:quoted-printable 'quoted-printable-decoder-stream)
|
(:quoted-printable 'quoted-printable-decoder-stream)
|
||||||
(:base64 'base64-decoder-stream)
|
(:base64 'base64-decoder-stream)
|
||||||
(t '8bit-decoder-stream))
|
(t '8bit-decoder-stream))
|
||||||
:stream (open-file-portion file-portion)))
|
:underlying-stream (open-file-portion file-portion)))
|
||||||
|
|
Loading…
Reference in a new issue