From: kapheine@... (Zachary P. Landau) Date: 2004-01-23T04:25:00+09:00 Subject: REXML and IOSource [I posted this earlier but it never showed up. If this is a repeat, I apologize.] Hello, I'm having some trouble using REXML's parse_stream with an IOStream (a stream returned from TCPServer.accept, to be specific). The data is being received from the socket just fine, but when I call REXML::Document.parse_stream(stream, self) it blocks until all of the XML has been received. I've traced the problem to REXML::SourceIO. Here is the section with the problem (shortened in parts to make it smaller): class IOSource < Source def initialize(arg, block_size=3D500) ... super @source.readline('>')+@source.read end end So the code seems to block until it is all read. I'm not sure of the purpose of having the readline first, since it reads the XML until it reaches a >, and then reads the rest. Seems kind of pointless. There's some commented out code that was from before readline was used, which reads 500 bytes at a time. This worked because it didn't block, but the best solution seems to be replacing the above super line with: super @source.readline('>') So I guess my question is, why is the +@source.read there? Is it a mistake, or am I missing something? I can fix the problem by redefining the initializer for IOSource, but then 1) I get a warning and 2) it seems like either a bug should be fixed or my understanding of what is going on should be fixed. -- Zachary P. Landau GPG: gpg --recv-key 0x24E5AD99 | http://kapheine.hypa.net/kapheine.asc