REXML and IOSource

Z

Zachary P. Landau

[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('>')[email protected]
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 (e-mail address removed) 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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top