Re: libwww and MIME-tools

Gisle Aas (gisle@aas.no)
02 Jul 1998 21:32:49 +0200


Joern Clausen <joern@techfak.uni-bielefeld.de> writes:

> Has anybody tried to use libwww and MIME-tools in one program? I'd like
> to PUT some multipart/mixed message somewhere.
> 
> I have the impression, that combining these two modules is (unnecessarily)
> complicated, as MIME-tools deals mostly with IO::Handles, instead of
> raw data, but I might be wrong here.

You always have an IO::Scalar object to collect the stuff.  Using
temporary files should not be too ugly either.

> Another thing is, that I end up
> doing things like
> 
>    $req->header('Content-Type' => $msg->head->get('Content-Type'));
> 
> where $req is a HTTP::Request and $msg is a MIME::Entity. I'd like
> to stuff the headers of the MIME object into the HTTP header, and this
> seems somewhat awkward.

I have never used the MIME-tools for anything yet.  If you were going
the other way it should just be:

  $req->scan(sub{ $msg->head->add(@_) });

> And, no, I'm not talking about a loop that does this.

Oh!

> Hm, is it possible to inherit from both classes, and have an
> object that is both an HTTP::Request *and* a MIME::Entity at the same
> time?

Don't think that would be wise :-(

It should be possible to just wrap a MIME::Entity into an adaptor
object that implements the HTTP::Request interface and then just send
this off with LWP.

Regards,
Gisle