3.7/3.8 FileStream compatibility and Seaside/KomHttpServer

Yoshiki Ohshima yoshiki at squeakland.org
Sun Mar 6 18:41:25 UTC 2005


  Ned,

> Rather than slurping the entire file into memory, why not just
> 
> fileStream := FileDirectory default readOnlyFileNamed: fullFilePath.
> fileStream ifNil: [^ false].
> fileStream converter: nil.
> HttpResponse current: (HttpResponse fromStream: fileStream.

  As I wrote in previous email.  Keeping opened files *may* not be too
sensible, either.  Anyway, the point is to use binary stream.

  (The above code doesn't work on non-Latin1 environment.)

> or even:
> 
> fileStream := StandardFileStream readOnlyFileNamed: (FileDirectory default 
> fullNameFor: fullFilePath).
> fileStream ifNil: [^ false].
> HttpResponse current: (HttpResponse fromStream: fileStream).

  StandardFileStream should be removed at one point.  Not in 3.8, but
in the future releases.  I wouldn't recommend to use it.

> The problem with calling #binary is that it changes the interface to the 
> stream: #next and #next: return SmallInteger and ByteArray objects instead of 
> Character and String objects.

  Of course.

  It is more conceptual correctness matter.  If you handle Characters
and Strings, it should be Characters and Strings.  But what you handle
are Integers and ByteArrays, use Integers and ByteArrays.

  What the server does is to read the file and feed the data into a
Socket.  So, All code between them should agree with the
SmallInteger-ByteArray protocol.  On the other hand, if the server has
to 'read' the internal of the file as text, it should know the
encoding in some way.

-- Yoshiki



More information about the Squeak-dev mailing list