Closed kibook closed 5 years ago
The write
method called should be determined by the run-time types of both arguments. stream
must already be a <response>
, otherwise as(<response>, stream)
would err. I surmise that buffer
is not a <byte-string>
and that's why it was failing to call write(<response>, <byte-string>)
. Could you verify that?
Rather than copy the buffer with as(<byte-string>, buffer)
I think it would be better to define a write(<response>, <sequence>)
method next to the write(<response>, <byte-string>)
method. (Keep the original method so that byte strings remain relatively fast.)
It's a good idea to have a more general method there because this is an easy mistake to make and it's better to work and be slow than to pretend to work.
Yes, the buffer used in copy-to-end
was just <sequence>
, which was why the write
method in server/core/response.dylan
wasn't being called.
kibook, it would be good if you could remove the reverted change from this pull request before we merge it. Otherwise it looks good. Thanks!
The
<response>
type has a specialized version ofwrite
andwrite-element
defined inserver/core/response.dylan
for<response>
and<byte-string>
, butcopy-to-end
here instead called a more generic version for<stream>
and<sequence>
.This meant the
<response>
was being written to as a normal stream, instead of using themaybe-send-chunk
method and writing toresponse.response-stream
.Coercing the parameters to the types expected by the
write
andwrite-element
methods inserver/core/response.dylan
fixes an issue with<directory-resource>
serving static files.