Hi list, CTHandler>>push: aStringI'm working on some streamed responses but I have some troubles to pass the information to the user. More specifically I'm working with Comet, based on the code made by Lukas on Squeak and the WAListener. How do I get the HTTPStreamedResponse? Well, in the "CTSession>>incomingRequest: aRequest" I specifically ask for it, and then I work with the message "HTTPStreamedResponse>>nextPutAll:aByteStringOrArray". The thing is that the stream (a SwazooStream) of the HTTPStreamedResponse hasn't be flushed, and so the data will never be send it to the client. Do I have to manually set the the state of the HTTPStreamedResponse by hand to #header in order to force a flush? Do you have some hints or similar so I can make a better approach? A note: I know that if I capture the stream in each connect of each handler in Comet, doing some ugly code like: CTHandler>>basicConnect: aRequest [...] stream := aRequest nativeRequest task response stream. stream nextPutAll: [ a page of seaside]. stream flush. And then in each push of data to the client I do: socket nextPutAll: aString the things work right. But I'm quite sure that the approach should be using the HTTPStreamedResponse class. Thanks for reading :) Bye, Lautaro Fernández PS: If I'm not clear, please tell me and I'll do my best to explain it in other way. -- Luke LAut SkyFernadezWalker ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Swazoo-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/swazoo-devel |
Hi Lautaro,
Streamed response do the actual send to the socket automatically in two cases: when you fill an 8K buffer and when you send aStreamedResponse close. If you like to control sending you need to flush manually by aStreamedResponse flush. This is done so because of proper packaging of packets for the TCP. If I would flush after every nextPutAll: there would be many very short packets, which is not very efficient. This problem had the Swazoo 1.0. You must get a streamed response from your request: aRequest streamedResponse That way a response will be properly initialized for streaming. I hope this help. Janko Lautaro Fernández wrote: > Hi list, > I'm working on some streamed responses but I have some troubles to pass > the information to the user. > More specifically I'm working with Comet, based on the code made by > Lukas on Squeak and the WAListener. > > How do I get the HTTPStreamedResponse? > Well, in the "CTSession>>incomingRequest: aRequest" I specifically ask > for it, and then I work with the message > "HTTPStreamedResponse>>nextPutAll:aByteStringOrArray". > > The thing is that the stream (a SwazooStream) of the > HTTPStreamedResponse hasn't be flushed, and so the data will never be > send it to the client. > > Do I have to manually set the the state of the HTTPStreamedResponse by > hand to #header in order to force a flush? Do you have some hints or > similar so I can make a better approach? > > A note: > I know that if I capture the stream in each connect of each handler in > Comet, doing some ugly code like: > CTHandler>>basicConnect: aRequest > [...] > stream := aRequest nativeRequest task response stream. > stream nextPutAll: [ a page of seaside]. > stream flush. > > And then in each push of data to the client I do: > CTHandler>>push: aString > socket nextPutAll: aString > > the things work right. But I'm quite sure that the approach should be > using the HTTPStreamedResponse class. > > Thanks for reading :) > Bye, > Lautaro Fernández > > PS: If I'm not clear, please tell me and I'll do my best to explain it > in other way. > -- > Luke LAut SkyFernadezWalker > > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > > > ------------------------------------------------------------------------ > > _______________________________________________ > Swazoo-devel mailing list > [hidden email] > https://lists.sourceforge.net/lists/listinfo/swazoo-devel -- Janko Mivšek AIDA/Web Smalltalk Web Application Server http://www.aidaweb.si ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Swazoo-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/swazoo-devel |
Hi Janko,
2008/9/2 Janko Mivšek <[hidden email]> Hi Lautaro, Thanks for your quickly answer! If I do "myHttpStreamedResponse flush" inside my "push:" method I get nothing in the client side. Seems like no data was send into the browser, but actually was. The hack I could find until now, is to force the streamed response to be #streaming (and not #header) before the first "nextPutAll:". Because of that "HTTPStreamedResponse>>sendHeaderAndStartStreaming" will never be called, and the header won't be written. So, the code looks like: CTHandler>>basicConnect: aRequest [...] streamedResoponse := aRequest nativeRequest streamedResponse. streamedResoponse nextPutAll: [ a page of seaside]. "streamedResoponse flush. no flush here, just in each push!" And then in each push of data to the client I do: CTHandler>>push: aString streamedResoponse nextPutAll: aString. streamedResoponse flush. I don't know if I'm doing something wrong, but the problem is in the method: HTTPStreamedResponse>>sendHeaderAndStartStreaming [...] self writeHeaderTo: self stream. <-------- here self stream flush. "to push sending of header immediately" self shouldBeChunked ifTrue: [self stream setChunked]. <------ and here self setStreaming. Is kind of that the header is writing something wrong in someplace, maybe is the page of seaside that I'm putting in it. Explanation of the seaside page: is a counter with two anchors (+1 and -1). Each click trigger a message to the server, and then the server pushes some data (the one who is not shown) in the client. Do you think that the problem is the header part of the streamed response? Thanks in advance Lautaro Fernández This is done so because of proper packaging of packets for the TCP. If I -- Luke LAut SkyFernadezWalker ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Swazoo-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/swazoo-devel |
Lautaro Fernández wrote:
> Streamed response do the actual send to the socket automatically in two > cases: when you fill an 8K buffer and when you send aStreamedResponse > close. If you like to control sending you need to flush manually by > aStreamedResponse flush. > > > Thanks for your quickly answer! > If I do "myHttpStreamedResponse flush" inside my "push:" method I get > nothing in the client side. Seems like no data was send into the > browser, but actually was. > > The hack I could find until now, is to force the streamed response to be > #streaming (and not #header) before the first "nextPutAll:". > Because of that "HTTPStreamedResponse>>sendHeaderAndStartStreaming" will > never be called, and the header won't be written. Streaming state is changed from #header to #streaming automatically at first #nextPutAll:, so this is not the problem. But it looks like you didn't set any response headers at all? You should set all correct headers before you start streaming, because those headers must be sent first, before streaming occurs. I would also inspect stream collection (asString) to see, what is actually streamed and why. Also, some net spying could help a lot here, with tools like Ethereal. Janko > So, the code looks like: > > CTHandler>>basicConnect: aRequest > [...] > streamedResoponse := aRequest nativeRequest streamedResponse. > streamedResoponse nextPutAll: [ a page of seaside]. > "streamedResoponse flush. no flush here, just in each push!" > > And then in each push of data to the client I do: > CTHandler>>push: aString > streamedResoponse nextPutAll: aString. > streamedResoponse flush. > > I don't know if I'm doing something wrong, but the problem is in the method: > HTTPStreamedResponse>>sendHeaderAndStartStreaming > [...] > self writeHeaderTo: self stream. <-------- here > self stream flush. "to push sending of header immediately" > self shouldBeChunked ifTrue: [self stream setChunked]. <------ and here > self setStreaming. > > Is kind of that the header is writing something wrong in someplace, > maybe is the page of seaside that I'm putting in it. > > Explanation of the seaside page: is a counter with two anchors (+1 and > -1). Each click trigger a message to the server, and then the server > pushes some data (the one who is not shown) in the client. > > Do you think that the problem is the header part of the streamed response? > > Thanks in advance > Lautaro Fernández > > This is done so because of proper packaging of packets for the TCP. If I > would flush after every nextPutAll: there would be many very short > packets, which is not very efficient. This problem had the Swazoo 1.0. > > You must get a streamed response from your request: > > aRequest streamedResponse > > That way a response will be properly initialized for streaming. > > I hope this help. > Janko > > Lautaro Fernández wrote: > > Hi list, > > I'm working on some streamed responses but I have some troubles > to pass > > the information to the user. > > More specifically I'm working with Comet, based on the code made by > > Lukas on Squeak and the WAListener. > > > > How do I get the HTTPStreamedResponse? > > Well, in the "CTSession>>incomingRequest: aRequest" I > specifically ask > > for it, and then I work with the message > > "HTTPStreamedResponse>>nextPutAll:aByteStringOrArray". > > > > The thing is that the stream (a SwazooStream) of the > > HTTPStreamedResponse hasn't be flushed, and so the data will never be > > send it to the client. > > > > Do I have to manually set the the state of the > HTTPStreamedResponse by > > hand to #header in order to force a flush? Do you have some hints or > > similar so I can make a better approach? > > > > A note: > > I know that if I capture the stream in each connect of each > handler in > > Comet, doing some ugly code like: > > CTHandler>>basicConnect: aRequest > > [...] > > stream := aRequest nativeRequest task response stream. > > stream nextPutAll: [ a page of seaside]. > > stream flush. > > > > And then in each push of data to the client I do: > > CTHandler>>push: aString > > socket nextPutAll: aString > > > > the things work right. But I'm quite sure that the approach should be > > using the HTTPStreamedResponse class. > > > > Thanks for reading :) > > Bye, > > Lautaro Fernández > > > > PS: If I'm not clear, please tell me and I'll do my best to > explain it > > in other way. > > -- > > Luke LAut SkyFernadezWalker > > > > > > > ------------------------------------------------------------------------ > > > > > ------------------------------------------------------------------------- > > This SF.Net email is sponsored by the Moblin Your Move > Developer's challenge > > Build the coolest Linux based applications with Moblin SDK & win > great prizes > > Grand prize is a trip for two to an Open Source event anywhere in > the world > > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > <http://moblin-contest.org/redirect.php?banner_id=100&url=/> > > > > > > > ------------------------------------------------------------------------ > > > > _______________________________________________ > > Swazoo-devel mailing list > > [hidden email] > <mailto:[hidden email]> > > https://lists.sourceforge.net/lists/listinfo/swazoo-devel > > -- > Janko Mivšek > AIDA/Web > Smalltalk Web Application Server > http://www.aidaweb.si > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's > challenge > Build the coolest Linux based applications with Moblin SDK & win > great prizes > Grand prize is a trip for two to an Open Source event anywhere in > the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > <http://moblin-contest.org/redirect.php?banner_id=100&url=/> > _______________________________________________ > Swazoo-devel mailing list > [hidden email] > <mailto:[hidden email]> > https://lists.sourceforge.net/lists/listinfo/swazoo-devel > > > > > -- > Luke LAut SkyFernadezWalker > > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > > > ------------------------------------------------------------------------ > > _______________________________________________ > Swazoo-devel mailing list > [hidden email] > https://lists.sourceforge.net/lists/listinfo/swazoo-devel -- Janko Mivšek AIDA/Web Smalltalk Web Application Server http://www.aidaweb.si ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Swazoo-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/swazoo-devel |
Lautaro,
Try also to close the streaming response after each complete page you send to the browser. This won't be Comet, I know, but you will easier isolate the problem. Janko Janko Mivšek wrote: > Lautaro Fernández wrote: > >> Streamed response do the actual send to the socket automatically in two >> cases: when you fill an 8K buffer and when you send aStreamedResponse >> close. If you like to control sending you need to flush manually by >> aStreamedResponse flush. >> >> >> Thanks for your quickly answer! >> If I do "myHttpStreamedResponse flush" inside my "push:" method I get >> nothing in the client side. Seems like no data was send into the >> browser, but actually was. >> >> The hack I could find until now, is to force the streamed response to be >> #streaming (and not #header) before the first "nextPutAll:". >> Because of that "HTTPStreamedResponse>>sendHeaderAndStartStreaming" will >> never be called, and the header won't be written. > > Streaming state is changed from #header to #streaming automatically at > first #nextPutAll:, so this is not the problem. But it looks like you > didn't set any response headers at all? You should set all correct > headers before you start streaming, because those headers must be sent > first, before streaming occurs. > > I would also inspect stream collection (asString) to see, what is > actually streamed and why. Also, some net spying could help a lot here, > with tools like Ethereal. > > Janko > > >> So, the code looks like: >> >> CTHandler>>basicConnect: aRequest >> [...] >> streamedResoponse := aRequest nativeRequest streamedResponse. >> streamedResoponse nextPutAll: [ a page of seaside]. >> "streamedResoponse flush. no flush here, just in each push!" >> >> And then in each push of data to the client I do: >> CTHandler>>push: aString >> streamedResoponse nextPutAll: aString. >> streamedResoponse flush. >> >> I don't know if I'm doing something wrong, but the problem is in the method: >> HTTPStreamedResponse>>sendHeaderAndStartStreaming >> [...] >> self writeHeaderTo: self stream. <-------- here >> self stream flush. "to push sending of header immediately" >> self shouldBeChunked ifTrue: [self stream setChunked]. <------ and here >> self setStreaming. >> >> Is kind of that the header is writing something wrong in someplace, >> maybe is the page of seaside that I'm putting in it. >> >> Explanation of the seaside page: is a counter with two anchors (+1 and >> -1). Each click trigger a message to the server, and then the server >> pushes some data (the one who is not shown) in the client. >> >> Do you think that the problem is the header part of the streamed response? >> >> Thanks in advance >> Lautaro Fernández >> >> This is done so because of proper packaging of packets for the TCP. If I >> would flush after every nextPutAll: there would be many very short >> packets, which is not very efficient. This problem had the Swazoo 1.0. >> >> You must get a streamed response from your request: >> >> aRequest streamedResponse >> >> That way a response will be properly initialized for streaming. >> >> I hope this help. >> Janko >> >> Lautaro Fernández wrote: >> > Hi list, >> > I'm working on some streamed responses but I have some troubles >> to pass >> > the information to the user. >> > More specifically I'm working with Comet, based on the code made by >> > Lukas on Squeak and the WAListener. >> > >> > How do I get the HTTPStreamedResponse? >> > Well, in the "CTSession>>incomingRequest: aRequest" I >> specifically ask >> > for it, and then I work with the message >> > "HTTPStreamedResponse>>nextPutAll:aByteStringOrArray". >> > >> > The thing is that the stream (a SwazooStream) of the >> > HTTPStreamedResponse hasn't be flushed, and so the data will never be >> > send it to the client. >> > >> > Do I have to manually set the the state of the >> HTTPStreamedResponse by >> > hand to #header in order to force a flush? Do you have some hints or >> > similar so I can make a better approach? >> > >> > A note: >> > I know that if I capture the stream in each connect of each >> handler in >> > Comet, doing some ugly code like: >> > CTHandler>>basicConnect: aRequest >> > [...] >> > stream := aRequest nativeRequest task response stream. >> > stream nextPutAll: [ a page of seaside]. >> > stream flush. >> > >> > And then in each push of data to the client I do: >> > CTHandler>>push: aString >> > socket nextPutAll: aString >> > >> > the things work right. But I'm quite sure that the approach should be >> > using the HTTPStreamedResponse class. >> > >> > Thanks for reading :) >> > Bye, >> > Lautaro Fernández >> > >> > PS: If I'm not clear, please tell me and I'll do my best to >> explain it >> > in other way. >> > -- >> > Luke LAut SkyFernadezWalker >> > >> > >> > >> ------------------------------------------------------------------------ >> > >> > >> ------------------------------------------------------------------------- >> > This SF.Net email is sponsored by the Moblin Your Move >> Developer's challenge >> > Build the coolest Linux based applications with Moblin SDK & win >> great prizes >> > Grand prize is a trip for two to an Open Source event anywhere in >> the world >> > http://moblin-contest.org/redirect.php?banner_id=100&url=/ >> <http://moblin-contest.org/redirect.php?banner_id=100&url=/> >> > >> > >> > >> ------------------------------------------------------------------------ >> > >> > _______________________________________________ >> > Swazoo-devel mailing list >> > [hidden email] >> <mailto:[hidden email]> >> > https://lists.sourceforge.net/lists/listinfo/swazoo-devel >> >> -- >> Janko Mivšek >> AIDA/Web >> Smalltalk Web Application Server >> http://www.aidaweb.si >> >> ------------------------------------------------------------------------- >> This SF.Net email is sponsored by the Moblin Your Move Developer's >> challenge >> Build the coolest Linux based applications with Moblin SDK & win >> great prizes >> Grand prize is a trip for two to an Open Source event anywhere in >> the world >> http://moblin-contest.org/redirect.php?banner_id=100&url=/ >> <http://moblin-contest.org/redirect.php?banner_id=100&url=/> >> _______________________________________________ >> Swazoo-devel mailing list >> [hidden email] >> <mailto:[hidden email]> >> https://lists.sourceforge.net/lists/listinfo/swazoo-devel >> >> >> >> >> -- >> Luke LAut SkyFernadezWalker >> >> >> ------------------------------------------------------------------------ >> >> ------------------------------------------------------------------------- >> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge >> Build the coolest Linux based applications with Moblin SDK & win great prizes >> Grand prize is a trip for two to an Open Source event anywhere in the world >> http://moblin-contest.org/redirect.php?banner_id=100&url=/ >> >> >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> Swazoo-devel mailing list >> [hidden email] >> https://lists.sourceforge.net/lists/listinfo/swazoo-devel > -- Janko Mivšek AIDA/Web Smalltalk Web Application Server http://www.aidaweb.si ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Swazoo-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/swazoo-devel |
In reply to this post by Janko Mivšek
2008/9/2 Janko Mivšek <[hidden email]> -- [...] But it looks like you didn't set any response headers at all? If I'm not wrong some response headers are written: (complete response is attached) HTTP/1.0 200 I think the problem is that I'm setting the headers two times, one on my response and the other one in the first run of "HTTPStreamedResponse>>nextPutAll:" (for the #header thing).Expires: Thu, 11 Jun 1980 12:00:00 GMT Cache-Control: no-cache, must-revalidate Pragma: no-cache Content-Type: text/html; charset=utf-8 [.........] You should set all correct headers before you start streaming, because those headers must be sent first, before streaming occurs. I'll check this and I'll post here my advances. I would also inspect stream collection (asString) to see, what is The stream is correct, as far I can see. Also, some net spying could help a lot here, I'll do this, but I hope not :) Thanks for your answer. Lautaro Luke LAut SkyFernadezWalker ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Swazoo-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/swazoo-devel response.txt (3K) Download Attachment |
Free forum by Nabble | Edit this page |