Creative Content for HTTP::Request

rjray on 2003-01-15T23:48:41

The HTTP::Message class of LWP (from which the HTTP::Request is a sub-class) allows a subroutine reference (or closure) as the argument to the content() method. When the content is given as this sort of reference, it is repeatedly called for data until it returns either undef or an empty string.

This will be key to my implementing streaming of messages in RPC::XML. But it isn't really documented at this point, so I thought I'd share.


Interesting

jjohn on 2003-01-16T00:19:37

I understand that you're trying to work around the large XML message problem. I take it you're not worried about validating this bloody message, rather you want to get at the data? Perhaps you'd consider just sending a pointer to the data which can then be served over standard HTTP. I think this solution keeps the XML message managable and lets RPC::XML do what it does best: small messages. I realize this is a somewhat unsettling suggestion, but I smells like the right solution to me. If you go down the road of reading the XML stream, it's not long before you start to think "Why read the rest of the XML message when I've finished reading the content I want?". Then XML becomes a hinderance, or at least an vestigal organ which future programmers will mock.

This problem is an interesting one. I'll be interested in how you implement your solution.

Re:Interesting

rjray on 2003-01-16T22:05:15

The problem is that the 3rd-party system we're working with uses an XML-RPC interface, but the data being sent is going to be huge. The goal is to avoid constructing the XML-RPC messages as in-memory strings, since they will be including base64 values that are encoded audio attachments.

The fact that I prefer not to back down on my existing compression support makes it harder, but I'm not going to back out a generally-useful feature like that in the name of a specific-requirement feature.

Matts made a good point that XLink would work really well in a case like this, but XML-RPC doesn't support that. And since this is a generalized remote-email interface, I can't reasonably ask them to implement oddness like recognizing a URL and downloading it to use as the attachment-in-question.

It's all terribly messy, and gets more and more frustrating with each passing day. Other problems and limitations have recently arisen, too, but at least most of those are someone else's headache.