Commit 4d6a6552 authored by Zach Beane's avatar Zach Beane
Browse files

Implement stream-bytes-written for zacl-sockets.

This seems to get the wrong answer for chunking sizes, but it's better
than hardcoding 42?
parent 5640d189
......@@ -31,16 +31,35 @@
:initarg :real-stream
:accessor real-stream
:reader underlying-input-stream
:reader underlying-output-stream)))
:reader underlying-output-stream)
:initarg :bytes-written
:initform 0
:accessor bytes-written)))
(defmethod stream-write-byte :after ((stream zacl-socket) byte)
(declare (ignore byte))
(incf (bytes-written stream)))
(defmethod stream-write-byte ((stream zacl-socket) byte)
(write-byte byte (real-stream stream)))
(defmethod stream-write-char ((stream zacl-socket) char)
(map nil (lambda (octet)
(write-byte octet (real-stream stream)))
(stream-write-byte stream octet))
(string-to-octets (string char))))
(defmethod stream-write-sequence :after ((stream zacl-socket) sequence
start end &key &allow-other-keys)
;; FIXME: Could be affected by string encoding?
(declare (ignore sequence))
(incf (bytes-written stream) (- end start)))
(defmethod excl::socket-bytes-written ((socket zacl-socket) &optional set)
(if set
(setf (bytes-written socket) set)
(bytes-written socket)))
(defmethod stream-write-sequence ((stream zacl-socket) sequence start end
&key &allow-other-keys)
(when (typep sequence 'string)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment