Sending multi-part MIME package via HTTP-POST

squishywaffle at squishywaffle at
Mon Oct 13 21:25:52 CEST 2008

This has got me somewhat stumped, so I'll throw it up here in hopes
that someone has ran into this before. I'm trying to send a MIME
package to Esko Backstage. I'm a bit confused as to how to send this
to the server in a manner that it'll be able to get and de-code the
MIME package in a valid way.

The big question is does this entire mime package belong in the
headers section of an HTTP request? If not, what is the best Pythonic
way to send this thing. I'm using 2.5's email package to create the
package and was trying to use its as_string() method to pump this
through httplib, but I'm getting a very vague server error message
that seems to indicate a malformed package. Here is the broken code:

        hcon = httplib.HTTPConnection(JMF_GATEWAY)
        hcon.putrequest('POST', JMF_GATEWAY_PATH)

I've pasted the string representation of the MIME package I'm trying
to send below. Any ideas would be greatly appreciated.

Content-Type: multipart/related;
MIME-Version: 1.0
start: cid:beginning

Content-Type: application/vnd.cip4-jmf+xml
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-ID: beginning

<?xml version="1.0" ?><JMF SenderID="QMon" Version="1.2"><Command
ID="Link1290_5" Type="SubmitQueueEntry"><QueueSubmissionParams
Hold="false" Priority="50" URL="cid:aJDF_1"/></Command></JMF>
Content-Type: application/vnd.cip4-jdf+xml
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-ID: aJDF_1

<?xml version="1.0" ?>
<JDF DescriptiveName="StepRepeatTab and RIP" ID="n0001"
Status="Waiting" Type="ProcessGroup" Version="1.2" xmlns="http://" xmlns:eg="
                <RunList Class="Parameter" DescriptiveName="1-up"
ID="SourceFileList" PartIDKeys="Run" Status="Available">
                        <RunList Run="Run0001">
                                        <FileSpec URL="/archive/49297
PEPPINOS/49297-1 DMT-20.pdf"/>
        <JDF DescriptiveName="RIP1up" ID="n0003" Status="Waiting"
Type="eg:BackStageTask" Version="1.2" xmlns="
JDFSchema_1_1" xmlns:eg="">
                <NodeInfo JobPriority="50"/>
                        <eg:BackStageTaskParams Class="Parameter"
ID="TaskParamLink" Status="Available" eg:Hold="false" eg:TicketName="/
                        <eg:BackStageTaskParamsLink Usage="Input"
                        <RunListLink Usage="Input"
                        <RunListLink Usage="Output" rRef="TIFFList"/>


More information about the Python-list mailing list