[patch] Fix static content serving in Swazoo

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[patch] Fix static content serving in Swazoo

Dmitry Matveev
Hello,

I have attached a patch that fixes the static content serving in Swazoo.
The following code demonstrates the case:

| site |
site := Swazoo.SwazooSite newNamed: 'hello'.
site host: '*' ip: '*' port: 8888.
site addResource: (Swazoo.FileResource uriPattern: '/' filePath: 'index.html').
site start.


There were two issues. In Swazoo.FileResponse >> printEntityOn:
aStream we have got MessageNotUnderstood exceptions on
1. rs lineEndTransparent
2. rs nextAvailable: 2000
...and no data were written on the stream.

A dummy #lineEndTransparent message was inserted into a Stream class
in swazoo-httpd/Extensions.st, but in Sport a SpFileStream (that is
used in Swazoo) is derived from Object, not from a Stream.

And then,  a SpFileStream did not provided a #nextAvailable: message,
I have added it.

Dmitry

_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: [patch] Fix static content serving in Swazoo

Dmitry Matveev
Oops, forgot to attach it.

2011/2/2, Dmitry Matveev <[hidden email]>:

> Hello,
>
> I have attached a patch that fixes the static content serving in Swazoo.
> The following code demonstrates the case:
>
> | site |
> site := Swazoo.SwazooSite newNamed: 'hello'.
> site host: '*' ip: '*' port: 8888.
> site addResource: (Swazoo.FileResource uriPattern: '/' filePath:
> 'index.html').
> site start.
>
>
> There were two issues. In Swazoo.FileResponse >> printEntityOn:
> aStream we have got MessageNotUnderstood exceptions on
> 1. rs lineEndTransparent
> 2. rs nextAvailable: 2000
> ...and no data were written on the stream.
>
> A dummy #lineEndTransparent message was inserted into a Stream class
> in swazoo-httpd/Extensions.st, but in Sport a SpFileStream (that is
> used in Swazoo) is derived from Object, not from a Stream.
>
> And then,  a SpFileStream did not provided a #nextAvailable: message,
> I have added it.
>
> Dmitry
>

_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk

swazoo-static-content.patch (984 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [patch] Fix static content serving in Swazoo

Paolo Bonzini-2
On 02/02/2011 11:24 PM, Dmitry Matveev wrote:
> +    nextAvailable: anInteger [
> +        | data stream read |
> +        data := Array new: anInteger.
> +        stream := WriteStream on: data.
> +        read := self underlyingStream nextAvailable: anInteger putAllOn: stream.
> +        ^data copyFrom: 1 to: read
> +    ]

Thanks for the patch!

But the above can be just

     nextAvailable: anInteger [
         ^self underlyingStream nextAvailable: anInteger
     ]

no?

Paolo

_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: [patch] Fix static content serving in Swazoo

Dmitry Matveev
2011/2/3, Paolo Bonzini <[hidden email]>:
> But the above can be just
>      nextAvailable: anInteger [
>          ^self underlyingStream nextAvailable: anInteger
>      ]
>
> no?
>

Oops, I have searched for such method, but haven't found it and wrote
own bicycle. :)

Dmitry

_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: [patch] Fix static content serving in Swazoo

Holger Freyther
In reply to this post by Paolo Bonzini-2
On 02/03/2011 08:41 AM, Paolo Bonzini wrote:

Hi Paolo,

your cset for Swazoo contains a diff header in Extensions.st. :)

_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: [patch] Fix static content serving in Swazoo

Paolo Bonzini-2
On 02/04/2011 08:43 PM, Holger Hans Peter Freyther wrote:
> On 02/03/2011 08:41 AM, Paolo Bonzini wrote:
>
> Hi Paolo,
>
> your cset for Swazoo contains a diff header in Extensions.st. :)

Fixed, thanks.

Paolo

_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk